Set monthly recurring job dynamically with resque-schedular

157 views Asked by At

Banging my head against the wall with this one. Trying to dynamically add jobs with resque-scheduler. What's the syntax for creating a monthly job? For example, the code below will set up a job to run every minute.

config[:class] = "job_name"
config[:args] = "arg"
config[:every] = "1m"
config[:persist] = true

What would the syntax here be for every month? Would it be config[:every] = "1 month"? I can't seem to find any answers on the resque-scheduler docs for this.

Thanks.

1

There are 1 answers

0
rafb3 On BEST ANSWER

For dynamic schedules resque-scheduler uses rufus-scheduler, as it is explained on the documentation, which handles not only the actual scheduling business but also the parse of the :every option.

You can see that when resque-scheduler runs it basically loads all schedule information from redis and then passes on to rufus.

The supported letter/durations are documented on rufus here as a map between letters and durations in seconds and you can see more complex rules on the specs for duration parsing.

For one month, you can use 1M or you can also use 4w, there's also 30d...