In this article, you will learn how to set up a cron job in Magento 2. Setting the cron jobs is an essential part to ensure the proper functioning of your Magento 2 store.
Configuring Cron Job via the Command Line
2. Once you’ve connected to the Magento server – find the PHP binary and php.ini path
To discover the path to your PHP binary, please type the following command:
A sample result will be as the following:
3. Execute the following command in order to edit the cron tab.
4. After this command has been performed – the cron tab editor will open.
5. To set up the cron jobs, paste the following lines of code:
* * * * * <path to php binary> <magento install dir>/bin/magento cron:run | grep -v "Ran jobs by schedule" >> <magento install dir>/var/log/magento.cron.log * * * * * <path to php binary> <magento install dir>/update/cron.php >> <magento install dir>/var/log/update.cron.log * * * * * <path to php binary> <magento install dir>/bin/magento setup:cron:run >> <magento install dir>/var/log/setup.cron.log
where <path to php binary> is the absolute file system path to your PHP binary, and <magento install dir> is your Magento root folder. For example, /var/www/mystore
This way your Magento 2 cron jobs should be up and running.