Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drupal maximum execution time of cron

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

like image 948
ArK Avatar asked Nov 13 '10 13:11

ArK


People also ask

What is Cron Drupal 8?

The term 'Cron' refers to the automated tasks that your site runs periodically. It takes care of, for example, checking whether or not updates are available for Drupal core, and for your contributed modules, and themes.

What is Cron Drupal 9?

Cron is a utility which executes commands at set intervals known as "cron jobs". According to drupal.org “A "cron job" is a time-triggered action that is usually (and most efficiently) performed by your website's hosting server, but can also be configured by a remote service or even from your own desktop”.

What is Cron Drupal 7?

Cron is a daemon that executes commands at specified intervals.

How do I run a cron job in Drupal?

Easiest - Enable Drupal cron You can manage "automated cron" via Manage > Configuration > System > Cron (admin/config/system/cron). On a new Drupal installation, this should be on by default which you can check at example.com/admin/modules. The default frequency is every three hours.


2 Answers

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.

like image 141
feedbackloop Avatar answered Sep 28 '22 11:09

feedbackloop


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.

like image 24
Mohammed J. Razem Avatar answered Sep 28 '22 12:09

Mohammed J. Razem