ruby-on-railsclockwork

How to trigger Clockwork task at the beginning of the month?


I would like to run task every beginning of the month. E.g.:

2017-01-01 00:00:00 // January has just started
2017-02-01 00:00:00 // February has just started ...
...

How to do this using clockwork?


Solution

  • Use:

    every(1.day, 'myjob', at: '00:00', :if => lambda { |t| t.day == 1 }) do ... end