Configure Cron Job in cPanel for Drupal Site

Drupal contains a file cron.php, which is responsible for handling maintenance tasks as cleaning up the log files, checking for updates, indexing for the search module, etc. The cron.php file is automatically installed during/with the drupal installation and simply loading the following URL will run the cron file for maintenance, etc.

http://www.example.com/cron.php

For example, to run the cron.php file of my drupal site, I just load the URL:

http://saurab.com.np/cron.php

For regular maintenance of the site, the cron.php file has to be called, either manually through the URL or automatically/periodically by setting up a cron job. In cPanel, “cron jobs” can be accessed in the Advanced tab.

A cron job can be added in the cron job page through the “Add New Cron Job” tab.

The “Common Settings” drop down contains various options as “Every Minute”, “Every 5 Minutes”, “Every Day”, etc. You can select any one of the default options provided the cron job to be called or run. Also, one can use custom settings provided in the Minute, Hour, Day, Month or Weekday drop down menus provided to run the cron daemon as required by the user.

In the “Command” input we enter the URL to the cron.php file as below:

wget http://www.example.com/cron.php >/dev/null

Pressing the “Add New Cron Job” button adds the cron job to run the specified command and “pings” the url http://www.example.com/cron.php which equivalents to loading the url in the address bar of the browser.

One can add any number of cron jobs in the cPanel interface. The cron jobs added in the cPanel are shown in the “Current Cron Jobs” tab in the cron jobs page of cPanel.

My cron job command is

0 11 * * 1 wget http://www.saurab.com.np/cron.php >/dev/null

which “pings” the url “wget http://www.saurab.com.np/cron.php” once a week on Monday (weekday -> 1) at 11 AM (Hour -> 11).

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.