MySQL Forums
Forum List  »  Performance

Re: Server just hanging (Copying to tmp table)
Posted by: Thomas Deliduka
Date: August 31, 2005 02:49PM

I created this script htat runs from the command line, initially (you can see the comented lines) I had it simply kill the queries that were running too long but I find that flushing tables actually accomplishes what I want without having to restart. Although as in my post above, I'm still kinda waiting to know if this action is going to kill the people on the websites who are surfing. So far I don't see any indications of that.

Anyway, here's the code, I have it set to run on the command line in a cron job.

#!/usr/bin/php
<?
mysql_connect("localhost","root","thepass");

$result = mysql_query("SHOW FULL PROCESSLIST");
$carray = array("Sleep","Killed","Locked");

while ($row=mysql_fetch_array($result)) {
$process_id=$row["Id"];

if ($row["Time"] > 60 && !in_array($row["Command"],$carray)) {
//$sql="KILL $process_id";
$sql = "FLUSH TABLES";
mysql_query($sql);
//echo "Killed: ". $row["Id"]." ".$row["User"]." ".$row["Host"]." ".$row["db"]." ".$row["Command"]." ".$row["Time"]." ".$row["State"]." ".$row["Info"]."\n";
echo "Flushed Tables";
break;
}
}
?>

I know enough to be dangerous. Thanks for being patient!

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Server just hanging (Copying to tmp table)
6252
August 31, 2005 02:49PM
8010
December 07, 2006 10:30AM
9380
September 23, 2005 01:56AM
4684
October 05, 2005 04:58AM
5840
October 05, 2005 11:49PM
5181
October 06, 2005 01:34AM
6401
October 06, 2005 04:57PM
6211
January 21, 2008 10:14AM
5632
January 21, 2008 10:53AM
5063
May 19, 2008 09:41AM
5317
February 05, 2008 10:27AM
5797
March 12, 2008 08:37AM
5900
November 14, 2008 12:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.