开发者

php/apache: allow larger max_execution_time for a CRON job?

I want run a php script weekly using a cron 开发者_如何学Gojob, however the script may take a few minutes or more.

Is there any way i can allow a greater max_execution_time just for this script?


You don't need to set a higher max_execution_time if you use PHP CLI: http://nl3.php.net/manual/en/features.commandline.differences.php


Maybe you should try these answers:

  • How do you get a Cronjob executing a PHP script to run longer than 30 seconds.
  • PHP command line: max_execution_time and memory_limit

But of course, using ini_set("max_execution_time",60) as the first php line in your job's script should do the trick.

Regards, Daniel


You can use set_time_limit(). If you want to disable timeout overall, pass it 0 as an argument. Otherwise pass it the number of seconds of max execution time.


You can use set_time_limit(0) at the start of your code: this removes the execution time limit altogether for this script. Note that it means that the script could run "forever", so put some checks in place in case it hangs.


set_time_limit

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜