Setting Up Cron

Last modified: April 5, 2009 - 10:00

This page is for beginners; more complete information can be found on the main cron page. If you can understand that page, then use it first.

I could not get a decent answer from the Drupal site on setting up the Cron jobs that it keeps complaining about. Nor would my hosting support people help ("That's a user problem...").Cron is a Unix command that allows you to set things up to be run on a schedule. There are things in Drupal that run on a timed basis, if Cron is available.

My hosting provider does not allow me to have Shell access (probably a wise move). Shell means you can get to the operating system to issue commands. Many hosts won't allow this. But they do provide the more-or-less-standard cPanel function. On my version, the "Cron" entry is in the lower left.

I also had WebCalendar installed on one of my sites. When I went to cPanel, I noticed that WebCalendar had a command already set up. Modifying it a bit, this is what I came up with to put in:
cd '/home/<i>username</i>/public_html/' ; php -q 'cron.php';

Note that username is my host's user ID for domain management and my Drupal installation is in my "root" folder (actually "public_html").

This worked for getting Cron run, but did generate some error messages.

I was happy that Cron ran, but a bit concerned about those messages. So I did some searching on the Drupal site and came up with several posts of the same messages, but no solutions. So I posted again. This time someone saw it through.

They suggested using WGET, but I don't have shell access. But I did, for some reason, check the "Advanced" mode on cPanel again. I noticed that there was now a helpful hint there (of course in a small font). It said to use GET http://nanwich.info/cron.php (obviously, use your own URL). I did and the error messages went away and Cron is working great!

For Cron jobs another possibility is http://drupal.org/project/poormanscron

For every page view, this module checks to see if the last Cron run was more than 1 hour ago (this period is configurable). If so, the Cron hooks are executed, and Drupal is happy. These Cron hooks fire after all HTML is returned to the browser, so the user who kicks off the Cron jobs should not notice any delay.

 
 

Drupal is a registered trademark of Dries Buytaert.