Board logo

标题: php 批量删除mysql sleep进程 [打印本页]

作者: xiexie    时间: 2013-1-22 11:14     标题: 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\">";
?>





欢迎光临 PHP开发笔记 (http://phpvi.com/) Powered by Discuz! 6.1.0