4

I have tried below code but it is not working.

<crontab>
    <jobs>
        <send_customer_emails>
            <schedule>
                <cron_expr>0 0 */7 * *</cron_expr>
            </schedule>
            <run>
                <model>emailmodel/observer::sendEmails</model>
            </run>
        </send_customer_emails>
    </jobs>
</crontab>

I have checked when I use below expression, it works.

* * * * *

Is it a magento bug? Or am I doing something wrong.

  • your cronjob code is perfect, may be having some issue with code. you can simply check by adding log in your "sendEmails" function in "emailmodel/observer" – Chirag Nandaniya Dec 30 '15 at 5:32
  • Possible duplicate of Schedule cron job every four hours – MagenX Dec 30 '15 at 13:02
  • The cron expression is not "perfect", it matches every day that's divisible by 7, i.e. the 7th of the month, the 14th, the 21th and the 28th. The answers, suggesting a cron expression for "once a week on weekday X" are therefore correct – Fabian Schmengler Dec 30 '15 at 14:12
2

Try this way:

//this will run every saturday midnight
<schedule>
     <cron_expr>0 0 * * 6</cron_expr>
</schedule>

* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

Hope this helps.

2

That should do it:

5 8 * * 6 <user> <command>

or for readability

5 8 * * Sat <user> <command>

documentation (man 5 crontab):

          field          allowed values
          -----          --------------
          minute         0-59
          hour           0-23
          day of month   1-31
          month          1-12 (or names, see below)
          day of week    0-7 (0 or 7 is Sun, or use names)

Sat 8:05AM run find

# Minute   Hour   Day of Month       Month          Day of Week        Command    
# (0-59)  (0-23)     (1-31)    (1-12 or Jan-Dec)  (0-6 or Sun-Sat)                
    5       8          *             *                Sat              /usr/bin/fi

Set up cron in Magento

In the Magento admin, go to: System > Configuration > Advanced > System > Cron (Scheduled Tasks) and configure cron jobs you wish to run.

You should know that Magento runs cron jobs even if you don't have a daily cron job configured. Whenever Magento receives a request, it checks if there are any cron jobs to be run. Therefore, having the daily cron job would only make sense if you had no requests for an entire day.

I hope this will help you.

  • Your cron explanation is for Linux, not for the Magento cron system, although there is much similarity. – 7ochem Jul 19 '17 at 7:26

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.