Cron jobs are a significant part of each Magento store. It uses for sending emails, import/export tools, indexing etc. That’s why it is important to configure crontab in the right way.
Configure crontab
First of all, we’ll introduce how to configure crontab:
Go to the terminal and type:
1 | crontab -e |
This command will open configuration file for editing. In this file, you should enter instructions for cron in the text format:
1 | minute hour day-of-month month day-of-week command |
For example, for executing a command every 15 minutes we need to type:
1 | */15 * * * * /path/to/command |
More details about time format you can find here https://en.wikipedia.org/wiki/Cron
Configure crontab for Magento 1.x
For configuring crontab for Magento 1.x, open crontab configurations by typing
1 | crontab -e |
Add the next line:
1 | */5 * * * * sh /path/to/folder/cron.sh |
Don’t forget to change /path/to/folder to real path to Magento folder.
Configure crontab for Magento 2.x
For configuring crontab for Magento 2.x, open crontab configurations by typing
1 | crontab -e |
Add next lines:
1 2 3 | * * * * * php /path/to/folder/bin/magento cron:run | grep -v "Run jobs by schedule" >> /path/to/folder/var/log/magento.cron.log * * * * * php /path/to/folder/update/cron.php >> /path/to/folder/var/log/update.cron.log * * * * * php /path/to/folder/bin/magento setup:cron:run >> /path/to/folder/var/log/setup.cron.log |
Don’t forget to change /path/to/folder to real path to Magento folder.
Ihor KlymchukTechnical Lead
- If you’re a newbie merchant and don’t know how to install Magento 2...
- Get frustrated when it comes to adding Magento multiple languages? Not a...
- Although it can take much time and efforts to migrate Magento 1 to Magento 2 it...
- If you don’t know how to create a custom cache type in Magento, this article...
- Find out about Magento Enterprise Cloud Edition in our article to get more from...
- Are you planning to turn your ordinary store into a great online mall but...
- This article is devoted to the best free Magento Themes. View the list of 7 the...
- In the Magento world, it becomes more and more popular to create Progressive...