code: Select all
function mysql_kill_proc($timeout) {
if($timeout == "") $timeout = 60; // might need to change this
$result = mysql_query("SHOW FULL PROCESSLIST");
while ($row = mysql_fetch_assoc($result)){
if($row["Time"] > $timeout AND $row["Command"] == "Sleep" AND $row["Info"] == "" AND $row["db"] <> ""){
mysql_query("KILL ".$row["Id"]);
}
}
mysql_free_result($result);
}I couldn't get some SQL processes to hang on purpose so thats why its not tested. Also I would try what Beatles suggested first, adding mysql_close(); to theend.php as this might be considered more of a bandaid than a solution.


