This tutorial is to show you how to set up your Drupal site to run the cron successfully.
Cron is an important part of Drupal. Cron is used for retrieving syndicated RSS feeds from other sites and syndicate datas from your own site. Cron is also used by many other Drupal modules to handle required background processing.
- Latest version of Drupal
- Server OS: Linux
- Server: Apache
- Website Backend: Cpanel
The Cron Script
Drupal comes with two version of the cron script, which we can find in the drupal directory.( /public_html/your-site-name.com/scripts)
We are using cron-lynx.sh for this tutorial.
Edit the script
Go to Cpanel and set the permission of cron-lynx.sh to 755 ( /public_html/your-site-name.com/scripts/cron-lynx.sh). After changing the permission open the cron-lynx.sh and you can see the following line already exist in the cron-lynx.sh
#!/bin/sh # $Id: cron-lynx.sh,v 1.3 2006/08/22 07:38:24 dries Exp $ /usr/bin/lynx -source http://yoursite.com/cron.php > /dev/null 2>&1
Note: You should write your real site name here.
Now copy the path to cron-lynx.sh (Which you can find on top left side of editing panel) and save the file after you have finished editing.
On the Cpanel homepage click on the button Cron jobs and create a new cron job by setting the time interval for cron to run.
You can set the time interval as often as every minute or every hour and so on.
- * * * * * (Every minute)
- */5 * * * * (Every 5 minutes)
- 0,30 * * * * (Twice an hour)
- 0 * * * * (Once an hour)
- 0 0,12 * * * (Twice a day )
- 0 0 * * * (Once a day)
- 0 0 * * 0 (Once a week)
- 0 0 1,15 * * (1st and 15th)
- 0 0 1 * * (Once a month)
- 0 0 1 1 * (Once a year)
On command copy and paste the ull path to cron.php (/home/sitename/public_html/cron.php)
Command should look like this;
- For Primary (main) Domain
2. For Addon Domain/Sub Domain
Note: Make sure that you have given a single space after php.
1. php /home/sitename/public_html/sitename.com/cron.php [GOOD]
2. php/home/sitename/public_html/sitename.com/cron.php [BAD]
Verify Cron job
We have to make sure that the crontab is working properly, inorder to check that let's set cron job to run every minute (* * * * *).
Now go to your site admin>logs and if you see a message somthing like Cron run completed everything is OK, if not double check the whole process again.
Now go back and set the time interval rom every minute to every hour or the time interval you want cron to run.
I hope you could find this tutorial helpul. If you have anysuggessions or comments please write it below.