Question

I am trying to implement cron job to write a log file with 1min interval. I have an issue while doing the same. I notice that cron job is not running automatically.

Each time when I run "PHP bin/Magento cron: run " then only cron job gets executed and the database gets populated. If each time I need to run that command then it does not serve as the purpose of corn job.

I follow this link to implement:

https://devdocs.magento.com/guides/v2.2/config-guide/cron/custom-cron-tut.html

Please help me for the same

Was it helpful?

Solution

Try this:

just run this command in terminal crontab -e then paste below code in terminal.

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

After pasting that code press CTRL + X key then you will see this message.

Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?

Now press Y now you will see this type of message.

File Name to Write: /tmp/{{you will see temp name}}/crontab Just press ENTER And cron set.

It will call every minute Magento cron and Magento will manage your extension's cron and run as per configured time.

After cron configuration you just need to flush the cache.

OTHER TIPS

Make sure all the paths are properly written and there are no extra spaces or anything like that:

In the CLI type: crontab -e and you should see your crons:

* * * * * <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

You can run:

php bin/magento setup:upgrade
php bin/magento index:reindex
php bin/magento cache:flush
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top