2

I have several cron jobs executing php scripts. The php scripts sometimes do some heavy jobs like updating hundreds of records at a time in a mysql table.

The problem is that the job should run every minute. However, it randomly misses and as a result does not execute every minute. Sometimes, it executes every 4-6 minutes, then back to every 1 minute, misses 2-3 times more and then normal again.

I am on centos 6.5

Please note that the php runs correctly and there is no problem whatsoever concerning the php scripts themselves since on the time it runs, I get the expected results and that there are about 10 more other similar scripts running at the same time (every minute or every 5 minutes for the other scripts)

Job:

/usr/bin/php "/var/www/html/phpScriptToExecute.php" >> /var/www/html/log/phpScriptLog.log 2>&1

My take is that it is maybe a problem with too many simultaneous scripts running concurrently, accessing the database at the same time.

Last information: No error in the /var/log/cron file or in the phpScriptLog.log file.

4

2 回答 2

1

原因可能是,您的 cron 作业执行时间超过 1 分钟,在脚本结束时打印出开始时间和结束时间以验证它。如果 cron 作业正在运行,linux 将不会再次执行它。

于 2015-02-04T07:18:44.710 回答
0

我的猜测是它导致了 ba PHP 致命错误,但您的 PHP 可能未配置为将错误消息发送到 stderr,这就是您的phpScriptLog.log为空的原因。您可以检查您的 php.ini(或仅使用 ini_set())以下内容:

  1. display_errors:如果您希望错误显示在 stderr 上,请将其设置为 on/true
  2. log_errors:如果要将错误消息发送到文件,请将其设置为 true
  3. error_log:将其指向您希望存储错误的文件

或者,如果您想要一个避免重叠 cron 作业的解决方案,那么这里有很多 SO。

于 2015-02-04T08:21:42.583 回答