2

I created a custom cron job and tested on local server, where it needs to run

bin/magento cron:run

two times simultaneously and then that custom job is created and scheduled.

why is it like that ?

  • 1
    did you setup CRON job on local ? – Pawan Sep 15 at 8:53
  • I didn't set it from Stores->Settings->Configuration->Advanced->System, is it due to this? something missing.. – Ajwad Syed Sep 15 at 9:14
  • if you set CRON, your module's cron job automatic get schedule you don't need to run cron manually. – Pawan Sep 15 at 11:27
  • Yes it runs automatically, but first time when we need to execute cron:run, at that time it needs to run twice the run command to get the job scheduled.. – Ajwad Syed Sep 15 at 11:45
  • that what i am saying, after set CRON, you don't need to run cron:run. based on your configuration in module it will run please check magento.stackexchange.com/questions/275556/… – Pawan Sep 15 at 11:55
3

Because its made to work like this.

It's from Magento documentation

"You must run cron twice: the first time to discover tasks to run and the second time — to run the tasks themselves. The second cron run must occur on or after the scheduled_at time for every task"

https://devdocs.magento.com/guides/v2.3/config-guide/cli/config-cli-subcommands-cron.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.