Set up independent "cron" maintenance jobs for drupal.

Popular open source CMS
KBleivik
Site Admin
Posts: 178
Joined: Tue Sep 29, 2009 6:25 pm
Location: Moss Norway
Contact:

Set up independent "cron" maintenance jobs for drupal.

Postby KBleivik » Fri Jan 31, 2014 2:18 pm

This is so important for some webmasters that we quote the whole section from the INSTALL.TXT file found in the root of drupal 7.26.

Many Drupal modules have tasks that must be run periodically, including the Search module (building and updating the index used for keyword searching), the Aggregator module (retrieving feeds from other sites), and the System module (performing routine maintenance and pruning of database tables). These tasks are known as "cron maintenance tasks", named after the Unix/Linux "cron" utility.

When you install Drupal, its built-in cron feature is enabled, which automatically runs the cron tasks periodically, triggered by people visiting pages of your site. You can configure the built-in cron feature by navigating to Administration > Configuration > System > Cron.

It is also possible to run the cron tasks independent of site visits; this is recommended for most sites. To do this, you will need to set up an automated process to visit the page cron.php on your site, which executes the cron tasks.

The URL of the cron.php page requires a "cron key" to protect against unauthorized access. Your site's cron key is automatically generated during installation and is specific to your site. The full URL of the page, with the cron key, is available in the "Cron maintenance tasks" section of the Status report page at Administration > Reports > Status report.

As an example for how to set up this automated process, you can use the crontab utility on Unix/Linux systems. The following crontab line uses the wget command to visit the cron.php page, and runs each hour, on the hour:

Code: Select all

0 * * * * wget -O - -q -t 1 http://example.com/cron.php?cron_key=YOURKEY


Replace the text "http://example.com/cron.php?cron_key=YOURKEY" in the example with the full URL displayed under "Cron maintenance tasks" on the "Status report" page.

More information about cron maintenance tasks is available at https://drupal.org/cron, and sample cron shell scripts can be found in the scripts/ directory. (Note that these scripts must be customized like the above example, to add your site-specific cron key and domain name.)

Return to “Drupal”

Who is online

Users browsing this forum: No registered users and 1 guest