Lets say I have two cronjobs:

    <schedule><cron_expr>0,10,20,30,40,50 * * * *</cron_expr></schedule>

    <schedule><cron_expr>9,19,29,39,49,59 * * * *</cron_expr></schedule>

If the cron runs every minute, its obvious that the buttom task will always execute one minute before the first task (or 9 minutes after, depends on perspective..)

However, some magento sites are configured to run cron every 5 minutes or more, instead of every minute. On those systems those two tasks will run together, which is fine, but I want to make sure they maintain their original order.

So my questions:

  • Am I guaranteed that the bottom task will execute before the top task, even if cron is every 5 minutes?
  • Am I guaranteed that the latter task will only start executing after the first task is done, and not simultaneously (provided it doesn't use any async calls)?

On my system it seems to be the case, but I want to make sure its the defined behavior and not just by luck.

1 Answer 1


In you case to be sure that your vendor_module_task2 is launched before vendor_module_task1 you can remvove your vendor_module_task2 configuration and launch the vendor_module_task2 function at the top of your vendor_module_task1 function.
Example :
- vendor_module_task1 call task1()
- vendor_module_task2 call task2()

public function task1()
   // call your task2() here
   // your task1() code here

There some possible issue in this case, you have no more control on your vendor_module_task2 configuration but in Magento there is no possibility to set cron order with that level of dependency.

  • thanks Mattheo, but the reason I'm not doing this is because its different cronjobs from different modules which should not be dependent, yet I want them to run in a certain order. I simplified it for the example above, but in reality it won't be pretty to merge them like this. also, I think I can benefit from understanding cron works better :)
    – Ronen Ness
    Commented Jan 25, 2016 at 10:47
  • OK I understand ;) In this case instead of calling other module in function can you use event / observer ? Replacing my example // call your task2() here by a cron_before_run_* event and using observer to call your other module ? You can also use this with a cron_after_run_*. In any case you should have a little dependency between your extensions and like I said there is no way by default in Magento to set order in cron call unfortunatly. Commented Jan 25, 2016 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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