Drupal Cron Jobs

A cron job is a OS task that runs routinely on a timer.

Drupal has some tasks that need to run periodically.

See hook_cron() in core.api.php.

Run drush cron -v to see cron jobs on your site:

 [info] Starting execution of comment_cron().
 [info] Starting execution of dblog_cron(), execution of comment_cron() took 6.57ms.
 [info] Starting execution of field_cron(), execution of dblog_cron() took 0.94ms.
 [info] Starting execution of file_cron(), execution of field_cron() took 1.4ms.
 [info] Starting execution of history_cron(), execution of file_cron() took 22.47ms.
 [info] Starting execution of node_cron(), execution of history_cron() took 0.78ms.
 [info] Starting execution of search_cron(), execution of node_cron() took 8.89ms.
 [info] Starting execution of system_cron(), execution of search_cron() took 10.02ms.
 [info] Execution of system_cron() took 20.06ms.
 [info] Cron run completed.

node_cron() sets the node.min_max_update_time state, which is used in search rankings (see node_ranking()).

By default, cron is enabled automatically: https://www.drupal.org/docs/administering-a-drupal-site/cron-automated-….

Configure cron at /admin/config/system/cron.

Default is to run every 3 hours. Cron jobs run when a page is loaded and it has been 3+ hours since the last run. This works well as a default method, but can slow down the page load that triggers cron. You can disable the automated drupal cron and use another method to call the cron url provided in the admin config page. For example, you can add a curl command to this url to your systems cron jobs.

Modules:

https://www.drupal.org/project/ultimate_cron

Works with existing cron hooks.

https://www.drupal.org/project/simple_cron

Implement your cron as a task by extending SimpleCronPluginBase.

 

How do you set up a cron job to run a routine data migration?