?? mysql_timeout.php
字號:
<?include "include/db.php";include "include/general.php";# Fetch a list of MySQL processes and kill any that exceed the timeout limit.# Config vars$query_timeout=10; # Timeout in seconds.$sleep_timeout=360;#$mysql_path="/usr/local/mysql-standard-5.0.15-osx10.4-powerpc/bin/";$mysql_path="/usr/bin/";$mysql_command=$mysql_path . "mysqladmin -h $mysql_server -u $mysql_username " . ($mysql_password==""?"":"-p" . $mysql_password);for ($s=0;$s<60;$s+=10) # Do this once every 10 seconds for a minute, then this can be scheduled as a cron job once per min. { # Fetch process list $list=explode("\n",shell_exec($mysql_command . " processlist")); #echo "<pre>"; #print_r($list); for ($n=3;$n<count($list)-2;$n++) { $vals=explode("|",$list[$n]); $id=trim($vals[1]); $type=trim($vals[5]); $time=trim($vals[6]); $info=trim($vals[6]) . " : " . trim($vals[7]); $query=trim($vals[8]); if ((($type=="Query") && ($time>$query_timeout) && strpos($query,"select")!==false) || (($type=="Sleep") && ($time>$sleep_timeout))) { # Kill this process. echo "killing $id... $info\n"; shell_exec($mysql_command . " kill " . $id); } } sleep (10); }?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -