Question

Whats the maximum execution time of cron. is it possible to modify it if so any side effects.

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top