Search code examples
ruby-on-railsrufus-scheduler

rufus scheduler first day months


I try to execute a cron every first day of the month.

I see how do on every first monday but no on first day.

scheduler.cron('00 12 * * mon#1') do
     # ...
end

I try with:

scheduler.cron('00 12 * * #1') do
  # ...
end

how I can do it?


Solution

  • The format is:

    ┌───────────── min (0 - 59)
    │ ┌────────────── hour (0 - 23)
    │ │ ┌─────────────── day of month (1 - 31)
    │ │ │ ┌──────────────── month (1 - 12)
    │ │ │ │ ┌───────────────── day of week (0 - 6)
    │ │ │ │ │
    * * * * *
    
    "0 12 1 * *"
    

    Reference: https://en.wikipedia.org/wiki/Cron#Configuration_file