Drupal How To: Setup Cron Jobs on bluehost (Updated)

Every Drupal install requires regular actions to handle maintenance tasks such as cleaning up log files and checking for updates. Cron.php is the file that Drupal uses to run the maintenance process.

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.

With the inclusion of the "Poormanscron" module within the Drupal 7 core, it is no longer necessary to set up a cron job on your web server. Instead, you can configure the frequency with which cron is run on Administration / Configuration / System / Cron.

In Drupal 6, you can do the same thing by installing the contributed Poormanscron module.


If however you are still running or are intending to run a version of Drupal 5 and below through bluehost below is the most convenient way of setting up a cron jobs.

For instance, if your site were www.example.com, loading the URL http://www.example.com/cron.php in your browser would run the maintenance.

This page is automatically set up when you install Drupal. Simply loading the URL will run the maintenance. Nothing more is required.

For a modest personal site, you might set up this cron job to run once a day. For a more active site you might want to run that job more often—perhaps every few hours or every hour. This regular visit will tell Drupal to perform its periodic tasks, and this will help keep your system running smoothly.

Cron jobs are scheduled by setting up a "crontab." A crontab is a text file that contains the commands to be run. This file can be created and edited either through the command line interface, or, if you manage your website through a web-based control panel such as cPanel or Plesk (bluehost uses cPanel), you will use the web interface.

Login to your cPanel at bluehost, and locate the 'Cron jobs' link under the Advanced menu.


To create your cron job, all you have to do is select how often you would like the cron triggered and the command (php script, shell script, etc) you want to run. For example this command will run your Drupal's cron.php script.

php -q /home/yoursite/public_html/cron.php

Where "yoursite" is the eight character default user name for your hosting package. Bluehost uses an eight character user name for each new package. This name is based off the domain name with extra characters if the domain name is less than eight characters. If the domain name is more than eight, the user name is the first eight characters.

Please NOTE: If your drupal installation is hosted in its own directory, you will need to add that directory after "public_html" Like this:

php -q /home/yoursite/public_html/yourwebfolder/cron.php

Once your CRON job is created it will be shown in the list like this:



No comments:

Post a Comment