Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails whenever gem: schedule task between two times?

Suppose I wanted to run a rake every x minutes between two times every day? How might I do that? Would between work? Or until? Or must I use cron syntax?

# Refresh daily scores
every 5.minutes, # :between '3pm' :and '1am' do ?
  rake "games:scores_refresh"
end
like image 293
iamse7en Avatar asked Dec 12 '25 23:12

iamse7en


1 Answers

A simple cron approach which should work:

every '*/5 15-23,0 * * *' do
  rake "games:scores_refresh"
end

Run rake job every five minutes for any hour starting between 3 pm and 11 pm and for the hour starting at midnight.

like image 178
steve klein Avatar answered Dec 15 '25 12:12

steve klein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!