We've been trying to figure out what the problem is here, and can't seem to get it. I'm hoping that someone here can help. We have been having frequent crashes and as I monitor SSH using the top function, it is showing that the MySQL connection has been opened for over 80 hours and is consuming nearly 20% of our memory usage.
We have a lot of cron scripts that run, but I don't think we need to use the mysql_close function. Is this normal? How would I go about closing the connection? All of our cron scripts connect to the Database using the wordpress wp-config file. So the scripts will all say something like
require_once('wp-config.php');
..... your code ........
Since we have thousands of cron scripts, we've created it in such a way to fopen a whole bunch of them. fclose is not being used. Could that be a reason for keeping the MySQL connections open? The multi fopen script looks like this.
$subdomain_array = array('sub1','sub2','sub3','sub4','sub5','sub6','sub7','sub8');
$count_subdomains = count($subdomain_array);
for ($x=0;$x<$count_subdomains;$x++) {
$cron_root_folder1 = "http://".$subdomain_array[$x].".domain.com/myscripts/";
$next_file1 = $cron_root_folder1."file_name.php";
$handle = fopen($next_file1,"r");
echo "<h1>".$subdomain_array[$x]."</h1>";
while ($buffer = fgets($handle)) {
echo $buffer;
}
echo "<br /><br />";
We have about 75 of these fopen scripts running at various times. If anyone can help, we would appreciate this SO much!
I should add that SSH is showing that I have 170 someodd processes sleeping. I'm guessing that mysql is one of those.