MySQL Forums
Forum List  »  PHP

PHP Maintenance script to clear unused connections
Posted by: Tobias Marx
Date: May 16, 2008 03:03AM

I have some untidy php code in some projects that do not properly close PHP connections - so sometimes the max connections are reached (500), although there are never more then 5 simultaneous connections.

I want to do a watchMySQLConnections.php script that reload PHP if there are too many connections - however I the exec does not work and I think there must be a better solution for such a maintenance script?


$result=mysql_query("show status like '%Max_used_connections%';");

list($variable, $value)=mysql_fetch_row($result);

echo $value."\n";

if ($value>100){
exec("sudo '/etc/init.d/mysql reload'");
mysql_query("flush status");
}


mysql_close();

Options: ReplyQuote


Subject
Written By
Posted
PHP Maintenance script to clear unused connections
May 16, 2008 03:03AM


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.