In this post, we will learn to set up cron on the server for Magento 2 cron. In Magento 2 development there are many configurations that need cron for the proper working of your Magento.
Some of the tasks which are handled by cron in Magento 2 are:
- Catalog price rules
- Newsletters
- Generating Google Sitemaps
- Customer Alerts/Notifications
- Reindexing
- Automatic updating of currency rates
Now we will be going to set up cron on the server.
Run the following command from the terminal
crontab -e
If you are logged in as root user you can specify the cronjob for the Magento file system owner only by specifying the username by using the -u switch.
crontab -u <magento file system user> -e
When you hit the above command, editor option will appear select anyone in which you are comfortable with. In the editor enter the following cronjob.
* * * * * <path to php binary> <magento install dir>/bin/magento cron:run
In my case I have used the following command.
* * * * * php /home/ayaz/www/html/mage2/bin/magento cron:run
The server setup is complete. Note that the cronjob is configured to run every minute. The schedule can be adjusted as needed. To verify the cron setup, check the cron_schedule table in your Magento database for entries resembling the following.
You can learn more on cron in this post: http://webkul.com/blog/magento2-setup-cron-config-path/
That’s all for cron setup on server for magento, you can query or give feedback in the comments below, it will help us in improving. Hope this post will help you. Thanks 🙂
Be the first to comment.