7

I have a bunch of cronjobs managed by whenever. Everything works fine, but I have a few hourly cronjobs that are all triggered at the same time, so I'd like to stagger them. Worst case scenario I'm able to update the crontab manually, but I'd really rather take of this in schedule.rb.

TL;DR - I would like to do something like:

every 1.hour, at: ":00" do #task 1
every 1.hour, at: ":10" do #task 2
every 1.hour, at: ":20" do #task 3

Thanks!

Daniel Tsadok
  • 573
  • 5
  • 10

2 Answers2

29

This can be done this way:

every :hour, at: 0 do #task 1
every :hour, at: 10 do #task 2
every :hour, at: 20 do #task 3
mikdiet
  • 9,859
  • 8
  • 59
  • 68
1

I'm using this for your case:

every '5 * * * *' do
  #do stuff here
end

This will launch at the 5 minute mark (every hour, every day, every month, every day of the week)

For other cases like this where whenever might not have a built in helper, check out this link

Andrei S
  • 6,486
  • 5
  • 37
  • 54
  • This seems to be an obvious feature. Is there any obstacle to contributing this to the gem yet, or is it just that nobody's gotten around to it yet? – Isaac Betesh Jul 09 '13 at 21:05