Cron job setup in Magento 2

It is important to correctly setup cron job for Magento 2 as some basic functions such as reindexing rely on cron job to execute.

Below is a typical cron job setup on a cPanel server with logging enabled.

* * * * * /usr/local/bin/php /path_to_your_magento_installation/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /path_to_your_magento_installation/var/log/magento.cron.log
* * * * * /usr/local/bin/php /path_to_your_magento_installation/update/cron.php >> /path_to_your_magento_installation/var/log/update.cron.log
* * * * * /usr/local/bin/php /path_to_your_magento_installation/bin/magento setup:cron:run >> /path_to_your_magento_installation/var/log/setup.cron.log

Make sure the jobs are set to run every minute if you’re using the default Magento configurations. If the interval is longer, e.g. every five minutes, the indexer scripts will be missed and a ‘One or more indexers are invalid‘ message will appear in the admin area.

One thought on “Cron job setup in Magento 2”

  1. Setting up cron job helps to let the user know about the deals and discounts, instead of sending emails manually, I was trying to setup cron job in Magento 2, Your post helped me a lot and here’ another post that helped in its configuration, https://www.cloudways.com/blog/magento-2-cron-job/, Hope it will help your readers as well.

Comments are closed.