Cron automated tasks overview

Last updated on
20 December 2017

Setting up cron is an important step in the installation of the website and assists in the maintenance of the site's assets for search results, checking for updates to Drupal core and modules, and removing temporary files.

A properly configured cron job manages a variety of tasks:

  • Updates the index of site content used by the Search module.
  • Queues feeds to be updated by the Aggregator module.
  • Checks for available updates for the Update Manager module.
  • Performs routine maintenance tasks, such as removing older rows from logs, for the System module.

What is cron?

Cron is a daemon that executes commands at specified intervals. These commands are called "cron jobs". Cron is available on Unix, Linux and Mac servers. Windows servers use a Scheduled Task to execute commands. The actual "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 server or even from your own desktop.

What actually happens is that the cron job visits the cron.php file in your website at a URL like You can find the exact address of the cron.php file in the Status report at Administration > Reports > Status report (admin/reports/status) in the section Cron maintenance tasks.

Enabling cron

The easiest way is to let Drupal do it for you (which it does by default) using its built-in "automated cron" system. You can manage the "automated cron" via Manage > Configuration > System > Cron (admin/config/system/cron). The default frequency is every three hours. Cron will then be triggered by end users visiting your site, no more frequently than every three hours. Note that for low-traffic sites it can also be desirable to create a cron job. If you want to disable the automated cron, change the 'Run cron every' drop down to 'never'.

The automated cron system is compatible with all systems because it doesn't actually involve the system's cron daemon. It works by checking at the end of each Drupal request to see when cron last ran and, if it has been too long, processing the cron tasks as part of that request. The two down-sides are (1) cron tasks will only run when Drupal is processing requests; and (2) the 'weight' (processing and memory) of running the cron tasks will be added to some arbitrary unknown page request, which may slow down those requests, and has the potential to exceed memory limits on a complex site.

The second way (which is applicable to any version of Drupal) is to create a cron job or use some other external (for Drupal) method of triggering its cron tasks, such as an external cron job service like EasyCron or Cronless. This is the more reliable of the two methods (because it will always run on schedule), and it uses fewer resources (because the cron processing is not added to a page request). Therefore this is generally the preferred way to run cron when you have the choice. Note that if you create a cron job, you may want to disable the "automated cron" system entirely.

Disabling "automated cron"

For performance reasons, or if you want to ensure that cron can only ever run from an external trigger, it may be desirable to disable the automated cron system.

You can disable it by setting the "Run cron every" value to "Never" (e.g., at Administration > Configuration > System > Cron (admin/config/system/cron).

Another way to disable cron in Drupal 8 is to add the following line to your settings.php:

$config['automated_cron.settings']['interval'] = 0;

Note that this fixes the setting at admin/config/system/cron to "Never", and administrative users cannot override it.