1

When I use expression

*/1 * * * *   // Every minute

it works fine. But when I use

* */24 * * *  // Every 24 hours

or

0 0 * * *    // Midnight

or

30 9 * * *  // 9:30 AM

it does not work. Could you please explain what I am doing wrong. My purpose is to run cron every day at specific time. Thanks.

EDIT

I have created a custom module Customer_Feedback. In its config.xml I have added

<crontab>
    <jobs>
        <customer_feedback_send>
            <schedule><cron_expr>0 12 * * *</cron_expr></schedule>
            <run><model>feedback/observer::sendEmail</model></run>
        </customer_feedback_send>
    </jobs>
</crontab>

But I can't see any entry for job code customer_feedback_send in cron schedule table. However this method works fine when I use

 <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
  • Can you tell us what kind of cron you are trying to run and what indicates that it didnt work? (an email error , or some other indication?) – MaierB Oct 24 '14 at 6:20
  • I have a clue, not quite an answer, maybe study the google_sitemaps module (not exactly sure of the namespace) but that one seems to execute properly for me, so maybe see what that one is doing (its cron is set in magento config) and maybe use it as a clue ? – MaierB Oct 24 '14 at 7:17
  • How are testing if the job runs every minute compared to if it runs less frequently? – Jonathan Hussey Oct 24 '14 at 8:44
  • I am inserting new row in a custom database table. The code for insertion is written in the funcion sendEmail(). We can also check if a cron job is scheduled from the cron_schedule table. I can see the entry when I use per minute expression. – piyush_systematix Oct 25 '14 at 10:57
1

1) the 2nd example doesn't make sense as it has no reference point of WHICH of the 24 hours it needs to run. (I dont think the cron job records when it begins and then knows ok, 24 hours from now execute again)

2) However the 3rd and fourth examples do look ok and are the correct protocol.

  • You are correct, the second example should be the same as the third for midnight (which of course is every 24 hours) with the hours just changed to when in that 24 hour period it should run i.e. 0 4 * * *. Also note that the * for minutes is wrong as this will cause the job to run every minute over that 1 hour period. – Jonathan Hussey Oct 24 '14 at 8:42

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.