How to Setup a Magento Cronjob
Magento has a number of tasks such as cleaning log files that need to be run automatically to maintain a healthy/functional store. To accomplish this Magento relies on a cron job that is periodically run by the server without administrative intervention.
The Magento can be run of two ways, through the shell cron.sh or by running a php file cron.php both of which are located in the root of the installation.
Setting up the Magento cronjob via shell access (SSH)
First, open the crontab
crontab -e
Then move to the end of the crontab (last line) and hit the return key to create a new line. Then add the correct syntax to run the cron.sh or cron.php file. Below are two commands to run the cron, either as in shell or directly via the php file. Please note use only one of the following commands in the crontab.
Calling PHP file directly (Replace domain and path to Magento with your store setup):
*/5 * * * * wget -O /dev/null -q http://www.example.com/path_to_magento/cron.php > /dev/null
Calling the shell script to run the cron (Replace /absolute/url/from/server/root with your server setup):
*/5 * * * * /bin/sh /absolute/url/from/server/root/cron.sh &> /dev/null
The save the crontab and exit.
Setting up the Magento cronjob via a Control Panel
In cPanel, Siteworx and most other hosting control panels there will be a cronjob manager. Select this option then use the following settings(Replace domain and path to Magento with your store setup).
Minutes: */5 Hour: * Day: * Month: * Weekday: *
Shell command:
Command: wget -O /dev/null -q http://www.example.com/path_to_magento/cron.php > /dev/null
Running PHP directly command:
/bin/sh /absolute/url/from/server/root/cron.sh &> /dev/null