1

Lets say I want a task to be scheduled every 6 hours on one day a week, every 2 weeks. How would I achieve this? I've used hour_of_day to add a specific hour to a weekly rule, but I'd like to avoid having to calculate each specific hour based off of the interval and start time, and adding them individually. Is it possible to chain rules? Like an hourly rule on top of a weekly one? When I add them as two separate rules, the hourly one fires independent of the weekly one, i.e. on days that wouldn't satisfy the weekly rule.

1 Answers1

0

If you want a task to simply run at a certain time, have you considered setting up a cron that invokes your script?

Read about cron and how to use it here

But, if you're totally invested in ice_cube, it seems that their documentation shows chaining is possible.

This might be what you need:

schedule.add_recurrence_rule IceCube::Rule.weekly(2).day(:monday, :tuesday).hourly(6)
yez
  • 2,368
  • 9
  • 15
  • Unfortunately, crons will not work, as the basic use case for the app is that its a free SAAS application for people to schedule medication tasks for family members, and many of the tasks will have non-termination repetitions. Ice Cube handles this perfectly, except that I'm now needing to do some tricky calculations. The line of code you shared results in `undefined method 'hourly' for #`, and is actually what I had tried in the first place. Thank you, though! – evanchurchill Aug 10 '15 at 17:48