开发者

drupal maximum execution time of cron

开发者 https://www.devze.com 2023-01-25 03:09 出处:网络
Whats the maximum execution time of cron. is it possible to modify it if so any side开发者_运维百科 effects.The accepted answer above is INCORRECT. Cron\'s time limit in Drupal is hardcoded to 240 sec

Whats the maximum execution time of cron. is it possible to modify it if so any side开发者_运维百科 effects.


The accepted answer above is INCORRECT. Cron's time limit in Drupal is hardcoded to 240 seconds. See the drupal_cron_run function in includes/common.inc, specifically these lines:

drupal_set_time_limit(240);

and

if (!lock_acquire('cron', 240.0)) {

(based on the source of Drupal 7.12)

So, there is no way to change this globally without hacking core. I have heard it suggested to call drupal_set_time_limit yourself inside of your hook_cron implementation, as doing so resets PHP's counter. However that won't help you when it's a third-party module implementing hook_cron.


Maximum execution time for Drupal's cron depends on your php.ini.

For example if you use wget -O - -q -t 1 http://www.example.com/cron.php as your cron command, apache's php.ini is used to determine the maximum execution time.

If you use php -f cron.php as your cron command, then php-cli's php.ini is used to determine the maximum execution time.

It is recommended to use php-cli for higher execution time, where you can set the maximum execution time from /etc/php5/cli/php.ini (if you use debian linux) and have no side effects on apache while cron runs.


I don't know if this is necessarily the case as I've just run the cron.php through my browser and I'm getting a max excution time error of 240 seconds while my max execution time in my php.ini is 1200 seconds. So somewhere besides my php.ini file Drupal is grabbing the max execution time.

That somewhere would be in the ./includes/common.inc or ./includes/locale.inc. Head into there and there are settings to adjust how long drupal will allow the cron to run for before giving up


This module can help you: Set Cron Time

0

精彩评论

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