1

我们一直试图找出问题所在,但似乎无法解决。我希望这里有人可以提供帮助。我们经常发生崩溃,当我使用 top 函数监控 SSH 时,它显示 MySQL 连接已经打开了 80 多个小时,并且消耗了我们近 20% 的内存使用量。

我们有很多运行的 cron 脚本,但我认为我们不需要使用 mysql_close 函数。这是正常的吗?我将如何关闭连接?我们所有的 cron 脚本都使用 wordpress wp-config 文件连接到数据库。所以脚本都会说类似

require_once('wp-config.php'); 
..... your code ........

由于我们有数千个 cron 脚本,因此我们以一种可以打开一大堆它们的方式创建它。fclose 没有被使用。这可能是保持 MySQL 连接打开的原因吗?多 fopen 脚本如下所示。

$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 />";

我们有大约 75 个这些 fopen 脚本在不同时间运行。如果有人可以提供帮助,我们将不胜感激!

我应该补充一点,SSH 显示我有 170 个正在休眠的进程。我猜mysql就是其中之一。

4

0 回答 0