Setting Up a CRON Job for Magento

Cron jobs are automated events that are triggered by the server. A lot of people think that the Magento cron runs automatically – but this is not the case.

When you have finished your Magento website and set it live on a server you MUST activate the Magento Cron – otherwise you may notice that the following functionality fails to work:

  • Newsletter
  • Sitemap Generation
  • Other extensions that rely on cron settings

To set up your cron you need to tell your server to execute Magento’s cron.php file every so often – normally every 10 minutes or 20 minutes – you can change this depending on how long it takes your cron to run (normally only a couple of seconds but if you have extensions that do a lot of processing you may want to extend the time between runs – the last thing you want is for a cron to overlap!).

I’m going to show you how to set this up within a Plesk control panel.

First of all navigate to your domain and then click on Crontab (sometimes called ‘Scheduled Tasks’). Within Crontab will be a list of users for the domain (normally your FTP users) – click on a user and then click on Schedule a Task for <user> (or sometimes just ‘Schedule New Task’).

This next page can be quite complicated to understand but essentially it’s where we are going to set the time and dates for our cron to run – and also the command that will be ran.

For a Magento cron we only really want it to run every 10 minutes or so. To do this we can enter the following into the fields:

  • Switched on = checked
  • Minute = */10 (star means ‘every’ – so here we’ve said every 10 minutes)
  • Hour = *
  • Day of the Month = *
  • Month = *
  • Day of the Week = *
  • Command = /usr/bin/php -f /var/www/vhosts/

So, above we have set our cron task to run every 10 minutes, every hour, every day, every month and to run the command:

/usr/bin/php -f /var/www/vhosts/

Or alternatively (and probably better in my opinion) run it via CURL:


Please note that you must edit this command to match your own server setup – it’s the path from the root of the server to the cron.php residing in your Magento installation (don’t copy/paste!).

That is pretty much all you need to do to get your cron up and running. I hope you enjoyed this quick tutorial!

  • Ricky

    Hi, nice post.
    this is enough to make the re-index running automatically?

    • Hi Ricky,

      Unfortunately not, though Magento tends to reindex itself wherever it can – upon saving products etc. Setting up the cron will just enable Magento’s extra features such as sitemap.xml generation, newsletter subscriptions and anything custom that you want to run via cron.

      If you’re having indexing issues then it might be worth having a word with your server company – there is an SSH script that can be ran to re-index – your server company could then run this process as a cron every night (for example) to help you out.

  • Prakhar Birla

    Running it via CURL will make you encounter PHP’s max_execution_time while there’s no time limit in the CLI version.

    • Hi Prakhar – good point – the only problem for me with the CLI version is on some servers it’s restricted to safe_mode – so depending on the scripts you’re running they may / may not execute correctly – CURL tends to run them unrestricted – but as you say – it’s pretty much the same as a ‘user’ visiting the script – therefore open to timeouts etc

  • Sam

    Great details bud,

    I am having problem with the email, tried as you have explained but no luck.Can you please help.

    No email is being sent after the order either to admin or customer.