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”

Leave a Reply

Your email address will not be published. Required fields are marked *