Search code examples
ruby-on-railswhenever

Rails whenever gem: each month on the 20th


I searched all over the internet for this, and the documentation isn't really talking about monthly jobs in specific. So I was hoping that someone here could tell me how to do this.

I've installed the whenever gem and all I need to know is the right syntax for this:

every :month, :on => '20th', :at => '02:00' do
  runner "Mailer.send_friend_sheet"
end

Hope someone can point me in the right direction..

Thanks!


Solution

  • Whenever doesn't support an :on option as far as I am aware, but you should be able to do

    every '0 2 20 * *' do
      runner "Mailer.send_friend_sheet"
    end
    

    The '0 2 20 * *' is simply the relevant cron syntax - see http://www.manpagez.com/man/5/crontab/