How to Setup Magento Cron Jobs (Demonstrated on cPanel)
Ever wonder how your newsletters, customer alerts & notifications are sent out or how your currency rates, Google sitemaps are updated in Magento? Well, if you don't add cron jobs, none of these things will happen unless you take care of them manually.
So what are cron jobs anyway? Well these are scheduled tasks that you setup to be done by your server automatically. For example, when you setup a Magento cron job, your server automatically visits the cron.php page on your site which triggers a Magento script that does all of the things that I mentioned earlier in this article -- automatically while you talk with distributors, ship out orders, take coffee breaks ;) and basically run your business. You can read more about this here.
In the video below, you can see how this is done in cPanel. Of course, if you are using a control panel other than cPanel, it's still possible to follow this guide. You basically just need to figure out where your cron job manager (aka task scheduler) is located. You can easily figure this out by visiting the help section of your web host's site.
Can't view the video? Watch it on YouTube
So to start simply figure out where your cron.php file is located. If you installed Magento in the root of your site, the file is in the root. If Magento is installed in a subdirectory such as 'store' then your cron.php file is in that directory.
So you basically have to edit the line 'http://www.yoursite.com/absolute/path/to/magento/cron.php' with your domain and the path to your cron.php file. If the file is in the root it would look like 'http://yourdomain.com/cron.php' and if your file is in a subdirectory such as 'store', then your URL would look like http://yourdomain.com/store/cron.php'.
The full line of code looks like this:
*/5 * * * * curl -s -o /dev/null http://www.yoursite.com/absolute/path/to/magento/cron.php
If you have cPanel just go to the advanced section and click on the Cron Jobs link. Then once on that page enter your email in the email section if you'd like to receive an email when the cron job runs. I recommend only entering an email for testing purposes. After you complete the test, you can remove the email to prevent your inbox from getting flooded.
Then just enter:
- */5 in the 'minute' field
- * in the 'hour' field
- * in the 'day' field
- * in the 'month' field
- * in the 'weekday' field
- curl -s -o /dev/null http://www.yoursite.com/absolute/path/to/magento/cron.php in the command field.
Again remember to change the URL to the appropriate value as explained above.