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!
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With