amitree / delayed_job_recurring

Extends delayed_job to support recurring jobs
MIT License
84 stars 33 forks source link

Schedule to run on 1st day of month #25

Closed bcavileer closed 5 years ago

bcavileer commented 6 years ago

How can I schedule to run on

1st day of month at 12:00am UTC? 1st day of week at 12:00am UTC?

If I figure this out I will post my solution here or commit changes if necessary.

Any help is appreciated!

afn commented 6 years ago

I believe you can do something like

run_every 1.month
run_at Time.now.utc.beginning_of_month
timezone 'UTC'

and

run_every 1.week
run_at Time.now.utc.beginning_of_week
timezone 'UTC'

(You could alternatively specify a string for run_at like run_at '2018-01-01T00:00:00Z' but that would be gradually less efficient over time, since this is how the next run time is computed)