hungneox
hungneox

Reputation: 9829

Magento cron_expr and cronjob

I don't understand why I have to setup cron to run magento/cron.php and also have to config the cron_expr.

*/5 * * * * /absolute/path/to/bin/php -f /absolute/path/to/magento/cron.php

<module>
  <schedule>
      <cron_expr>*/5 * * * *</cron_expr>
   </schedule>
   <run>
      <model>module/observer::myMethod</model>
   </run>
</module>

I think if we can magento/cron.php periodically then it is enough to run the method myMethod periodcally. Why we have to setup cron_expr? Sorry for my ignorance.

Upvotes: 0

Views: 1201

Answers (1)

monojit
monojit

Reputation: 605

I am giving you one small example suppose in your site you need to call one method periodically say 30 minutes (30 minutes interval) and you need another function/method which will execute in every 10minutes. How can you do this only only cron.php without cron_expr? That's why Magento populates the cron schedule table with jobs that should be executed in the future, along with timestamps for when they should be run.

In one of my project i have used magento cron and its works like a charm. I have used 5/6 method and using cron_expr i have given different different time schedule for every method.To execute all these configured tasks, only the cron.php will need to be run periodically, for example every 5 minutes. Basically, this script will check if it needs to run any tasks, and if it needs to schedule any future tasks.

Upvotes: 1

Related Questions