📄 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); }?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -