Setting Up A Cron Job for Magento
A Cron job is a scheduled task, a task that is performed every so often by the server without any user input. Cron jobs are important for lots of different reasons and when it comes to ecommerce they are a godsend.
Magento required Cron jobs for a few different reasons but the most important ones in my opinion are:
- Newsletter Sending
- Automatic Sitemap Generation
What you should do is set up your newsletters and sitemaps as normal through Magento. Schedule your times and basically follow the instructions on screen. When you set your dates/times etc the Cron Job will perform these tasks after that date/time has been reached. It is therefore beneficial to schedule your Cron Job to run every 10-15 minutes.
Magento uses a single file named cron.php to execute all its scheduled tasks – all that is required to be done is to schedule a cron job to execute that php every so often.
At Ecommerce Website Design we use a server that has Plesk installed – with plesk it is easy to schedule your Cron Jobs.
I will show you now how to set up your Cron Job through plesk.
First of all navigate into your domain and on your domain dashboard click CronTab.
Secondly once you are inside your Crontab select the name of your FTP user. In this case it is “swimming”.
Next you should click on the Add Scheduled Task for FTP user from the tools menu at the top of the screen.
Now the important bit – what you should do is schedule the task for every 10 minutes. To do this we use the following command in the minutes section – */10. Next we want this to execute every hour of every day of every month – so we simply add a * to all the other boxes.
The last thing to do is to actually perform a command for this scheduled event. In our case on our plesk servers (should be reasonably similar for most linux server paths) we use the following command:
/usr/bin/php -f /var/www/vhosts/mydomain.com/httpdocs/cron.php
Simply replace mydomain.com with whatever your domain is called e.g. e-commercewebdesign.co.uk
Here is a screenshot to better demonstrate:
Once your cron job has been saved you will see that Magento will now run your scheduled tasks at the date/time you inputted (or 10minutes after the actual time).
Thanks for visiting our magento blog – I hope you found this post useful – any questions please let me know!

May 5th, 2010
Nice post! Thanks for the awesome. I’ve been wondering how to get a cron job to integrate with Magento!
May 14th, 2010
Hi,
Actually i am new to magento and i would like to ask one thing regarding setting up cron job for Newsletter sending, i am using magento 1.4 version, i had add new template for newsletter and set the schedule time for that.
Default cron job setting is in magento, i have not changed yet, and set the cron.php on server. After all this the newsletter is not sending.
Is i want to add some thing extra here to send a newsletter?
Its my humble request for you to send me the procedure how to send the newsletter in magento 1.4 .
Thanks in advance.
Regards
Vikas Pal
vikaspalkec07@gmail.com
May 21st, 2010
Hi Vikas,
To send a newsletter you should schedule our cron job to run every 15 minutes or so – then you go into your newsletter section and schedule the run – make sure its in the future. Your cron job will only pick up on the schedule after its been done – so don’t be suprised if it doesn’t sent it straight away:
e.g if you set your cron job for every 15 minutes and your newsletter is due to send at 9am. You could find that it doesn’t send until 9.14am (the next time the cron job is run AFTER the event is supposed to happen)
To create your newsletter go to newsletter templates > create our newsletter.
Then go to newsletter templates and on the main page select queue newsletter from the drop down – you can select the start date from the top – hit save and this will be queued.
July 13th, 2010
[...] you have read my other post “Setting Up A Cron Job for Magento” you will know that magento has its own automated protocols for generating sitemaps and [...]
August 5th, 2010
I’m new to magento and you’re tutorials have helped me out so much thank you!
August 19th, 2010
Call Johnny at Tranquil Blue he’ll fix the problem for you.