[[security-cron]]

=== Configuring Cron Maintenance Tasks

[role="summary"]
How to run cron maintenance tasks using the core Automated Cron module, or by running them from outside the site.

(((Automated Cron module,configuring)))
(((Cron task,configuring)))

==== Goal

Check whether cron maintenance tasks are run regularly, and if not, either
install the core Automated Cron module or run cron maintenance tasks from
outside the website.

==== Prerequisite knowledge

<<security-cron-concept>>

// ==== Site prerequisites

==== Steps

. Review the _Status report_ (see <<prevent-status>>) to see when cron
maintenance tasks were last run.
+
If you installed the website using the core Standard installation profile (or
similar), then cron maintenance tasks might already be running via the
core Automated Cron module.  By default, these tasks are run about every three
hours.

. Choose whether to run cron maintenance tasks using the core Automated Cron
module, or by other means. The core Automated Cron module might not be suitable
for some websites because:
+
  * Each time someone accesses a page on the site, the module checks how long it
  has been since cron maintenance tasks have last run, and then runs them if
  necessary. If no one visits the website for a long time, cron maintenance
  tasks will not be run.
  * Cron maintenance tasks are run after the page has been generated. This means
  there is less time for the tasks to be run before various server timeouts are
  reached (for example, PHP execution timeout). If this happens, the logs (see
  <<prevent-log>>) will show error messages that cron is unable to complete.
  * There is a small https://en.wikipedia.org/wiki/Scalability[scalability] cost
  associated with the core Automated Cron module. This is because one of the web
  server's processes is occupied (and can't serve other web pages) until the
  cron maintenance tasks are complete.

. If you want to use the core Automated Cron module, first make sure it is
installed (it is installed with the core Standard install profile; see
<<config-install>> if it is not installed).
+
Next, configure the module to control how frequently cron maintenance tasks are
run. In the _Manage_ administrative menu, navigate to _Configuration_ >
_System_ > _Cron_ (_admin/config/system/cron_). Choose the desired interval in
the _Cron settings_ section, and click _Save configuration_.
+
--
// Cron configuration page (admin/config/system/cron).
image:images/security-cron.png["Configure the core Automated Cron module"]
--

. If you want to run cron maintenance tasks from outside the website, uninstall
the core Automated Cron module (see <<config-uninstall>>). Next, find the
cron URL. This URL is shown in the _Status report_ (see <<prevent-status>>), and
in the _Cron_ administration page (see previous step). The URL looks
like this:
_http://www.example.com/cron/0MgWtfB33FYbbQ5UAC3L0LL3RC0PT3RNUBZILLA0Nf1Re_
+
Whenever this URL is visited, cron maintenance tasks will run. Set up one of
the following schedulers to access this URL regularly:
+
  * https://www.drupal.org/node/23714[The Cron daemon] (Linux, OS X, Solaris,
  BSD)
  * https://www.drupal.org/node/31506[Scheduled Tasks] (Windows)
  * A cron SASS provider (software as a service)
  * A cron manager provided by your web hosting provider (see the documentation
  provided by your provider)


// ==== Expand your understanding

==== Related concepts

<<security-concept>>

==== Additional resources

* http://docs.drush.org/en/master/cron/[Drush page "Running Drupal cron tasks from Drush"]
* https://www.drupal.org/docs/7/setting-up-cron/overview[_Drupal.org_ community documentation page "Setting up cron"]


*Attributions*

Written and edited by https://www.drupal.org/u/dalin[Dave Hansen-Lange] at
https://www.advomatic.com/[Advomatic],
https://www.drupal.org/u/batigolix[Boris Doesborg],
and https://www.drupal.org/u/jhodgdon[Jennifer Hodgdon].
