How To Setup CRON For Magento 2

Posted on 24 June, 2017

In Magento 2 there are many settings which need to be done to set cron. So, in this technical note, we are going to let you know how to setup cron in Magento 2 server.

Some of the Built-In functionalities which are handled by cron in Magento 2 are:

  1. Newsletters
  2. Catalog price rules
  3. Reindexing
  4. Customer Alerts/Notifications
  5. Automatic updating of currency rates
  6. Magento emails
  7. Generating Google Sitemaps

To set cron in magento 2 you need to run the bellow command from the terminal :

crontab -e

You can also use the following command for specific file system user

crontab -u <magento file system user> -e

And write the command as bellow:

* * * * * <path to php binary> <magento install dir>/bin/magento cron:run

In our case we have written the following command that will run cron on every 5 minute.

*/5 * * * * php /var/www/html/magento2/bin/magento cron:run

Optional : If you want to see log of cron schedule then you can write as bellow :

* * * * * <path to php binary> <magento install dir>/bin/magento cron:run >> <magento install dir>/var/log/magentocron.log

In our case we have written the following command for to see log of cron schedule.

*/5 * * * * php /var/www/html/magento2/bin/magento cron:run >> /var/www/html/magento2/var/log/magentocron.log

You can also check cron schedule in your magento database in cron_schedule table you will be able to see cron schedule entries.

You can also set cron from admin panel of magento 2.

1. On the Admin panel go to Stores > Configuration.
2. Select System under Advanced in the panel on the left side.
3. Open the Cron section, and perform the following :

Image Credit :


Filled up required information save configuration.

Wow! you are done, you have set cron for magento 2 and this will be executed on every five minute, you can schedule cron (* * * * *) as per your requirement.

* * * * *
| | | | |
| | | | +---- Day of the Week   (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute            (range: 0-59)

I hope this Magento technical note helped you to set cron in Magento 2. Bookmark it for your future reference. Do comment below if you have any other questions or doubts on this technical note.

P.S. Do share this note with your team.

Rakesh Savaliya , eCommerce Engineer

Magento Technical Notes

About Emipro

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. Our customers are companies of all sizes ranging from startups to large enterprises who realize that they need a professional internet solution to generate revenue streams, establish proper communication channels, to achieve desired goals and streamline business operations. [....] Read More

Our writings seems informative ?

Subscribe for our Magento Technical Notes and get more amazing stuff directly to your inbox!

Post Your Review


Your Review has been posted

0 Comment(s)