On this page
Automated Cron
Drupal 8 and later versions provide an Automated Cron module. Earlier versions of Drupal referred to this as Poor Man's Cron.
We can find this core module in the core/modules/automated_cron directory of the Drupal installation.
It is installed by default in a standard installation and be configured on the Cron page in system configuration section.
Home > Administration > Configuration >System
/admin/config/system/cron
A site is configured with an interval of time (in seconds) that Drupal will then run all cron hooks, in configuration this setting can be seen at:
automated_cron.settings intervalCompared to Drupal 7
Drupal 7 already had an "automated cron system", but Drupal 8 moved it into a separate module to allow sites that don't use it at all not have any overhead from it.
Comparison to Manual Cron
The automated cron module has the disadvantage that it is triggered by a request, and the unlucky user who sends the request may experience a fairly long delay. For this reason, the automated cron is typically used by smaller sites that are unable to create a cron job manually, e.g. using the Linux crontab. If crontab is desired, Drupal console command may be used to simplify the configuration (rather than curling the long URL show in /admin/config/system/cron. Here is an example crontab entry (using Drush):
30 * * * * web_user cd /var/www/html/docroot && /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COLUMNS=72 ../vendor/bin/drush --uri=your.drupalsite.org --quiet cronThis would execute Drupal cron once per hour at 30 minutes after the hour.
Drupal Console is no longer maintained, so avoid using it. Here's example using it:
30 * * * * web_user /var/www/html/vendor/bin/drupal --root=/var/www/html/docroot cron:execute > /dev/null 2>&1Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion