php 批量删除mysql sleep进程
<?php
define('MAX_SLEEP_TIME', 10);
$hostname = "";
$username = "";
$password = "";
$connect = mysql_connect($hostname, $username, $password);
$result = mysql_query("SHOW PROCESSLIST", $connect);
$i = 1;
while ($proc = mysql_fetch_assoc($result)) {
if (($proc["Command"] == "Query" || $proc["Command"] == "Sleep") && $proc["Time"] > 10) {
echo "KILL{$i}: " . $proc["Id"].'<br>';
$i ++;
@mysql_query("KILL " . $proc["Id"], $connect);
}
}
mysql_close($connect);
echo "<meta http-equiv=refresh content=\"3; url=www.php\">";
?>