Periodic tasks that are performed automatically on you website's hosting server
Setting up cron is an important step in the installation of the website, and assists with tasks such as the maintenance of the site's assets for search results, checking for updates to Backdrop core and contributed projects, and removing temporary files.
A properly configured cron job can manage a variety of tasks:
- The Search module that indexes the website's content.
- The System module that performs routine maintenance tasks, such as pruning of logs.
- The Updater module that checks for module updates.
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 service 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
http://www.example.com/core/cron.php?cron_key=0MgWtfB33FYbbQ5UAC3L0LL3RC0PT3RNUBZILLA0Nf1Re. You can find the exact address of the cron.php file in the "Status report" page, at Administration > Reports > Status report (admin/reports/status), in the "Cron maintenance tasks" section.
There are two separate ways to run Backdrop's cron tasks:
1) Automated cron
The easiest way is to let Backdrop do it for you (which it does by default), using its built-in "automated cron" system.
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 Backdrop request to see when cron last ran. If it has been too long, the cron tasks are triggered as part of that request. The downside to this approach is that cron tasks will only run when Backdrop is processing requests.
By default in Backdrop the page request that triggers the cron tasks will still complete while the cron tasks run in the background. This option can be disabled in Administration > Configuration > Development > Performance if it causes other problems. (This is an innovation over Drupal 7 where 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.) This mitigates the problem of slow first-load of pages on sites with low traffic.
2) "Native" cron jobs, and 3rd-party, "external" cron services
The second way is to create a cron job, or use some other external (to Backdrop) 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.
You can configure the "automated cron" via the Administration > Configuration > System > Cron (admin/config/system/cron).
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).