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.

piyush_systematix
  • 2,014
  • 3
  • 27
  • 37

2 Answers2

3

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.

Adarsh Khatri
  • 8,360
  • 2
  • 25
  • 58
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.

Denish Vachhani
  • 4,562
  • 3
  • 16
  • 47
  • Your cron explanation is for Linux, not for the Magento cron system, although there is much similarity. – 7ochem Jul 19 '17 at 07:26