MagentoUncategorized

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

 

 

 

 

 

Hans-Eirik Hanifl

Hans-Eirik Hanifl is a forward thinking e-commerce and marketing consultant. As an advocate for the free exchange of knowledge, he founded E-Commerce Gorilla as a place where like-minded individuals can ask questions and share their expertise on practical solutions in the area of e-commerce and marketing. He is the owner of TRM Marketing and an avid supporter of the open source community.

Related Articles

Leave a Reply

Back to top button
Sign up to the E-Commerce Gorilla newsletter for updates & special promotions.
Join Our Newsletter
SUBSCRIBE
We value your privacy and protect your information like our own. Unsubscribe at anytime.