Reputation: 2209
I need to run a task precisely on 10AM every thursday,
on resque yaml file I am trying this
cron: "* 10 * * 4 * America/New_York" # expecting this to shoot out every thursday..
Was that correct? I can't test it out as I can't wait for such an interval, so I tried to test it at least for every 5 mins but it isn't very promising
cron: "5 * * * * *" # It runs for every single minute..
any help or direction is appreciated.
I followed this
* * * * * *
| | | | | |
| | | | | +-- Year (range: 1900-3000)
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month (range: 1-31)
| +---------- Hour (range: 0-23)
+------------ Minute (range: 0-59)
Upvotes: 0
Views: 1845
Reputation: 1061
Regex expressions can have 5 or 6 placeholders. Not every framework/implementation supports both ways so you have to check which format you need.
Your expression cron: "5 * * * * *"
would run every minute exactly 5 seconds past the minute.
I think in your case, you could use only 5 placeholders which means that you can not schedule for seconds but only for minutes.
Also, to run something every 5 minutes, you need the following expression:
cron: "*/5 * * * *"
Every 10AM on thursday should be:
cron: "0 10 * * 4 America/New_York"
Meaning:
(I have not tested this.)
Upvotes: 2
Reputation: 1961
There are normally only 5 fields for cron. The implementation of cron you are using allows 6 fields but the first field stands for seconds not minutes. From https://github.com/resque/resque-scheduler:
NOTE: Six parameter cron's are also supported (as they supported by rufus-scheduler which powers the resque-scheduler process). This allows you to schedule jobs per second (ie: "30 * * * * *" would fire a job every 30 seconds past the minute).
So you should drop to the normal 5 fields and use the @thomas-d's answer.
Traditional 5 field format is:
Minute Hour Day_of_the_Month Month_of_the_Year Day_of_the_Week
Upvotes: 2