Rails whenever gem: each month on the 20th

后端 未结 4 1911
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 14:20

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

4条回答
  •  囚心锁ツ
    2021-02-02 14:44

    You can use raw cron syntax as well if you cant figure out how to use with ruby syntax.

    What you want will look like:

    every '0 2 20 * *' do
      command "echo 'you can use raw cron syntax too'"
    end
    

    Here is a quick cheatsheet for how to use cron syntax

    *     *     *   *    *        command to be executed
    -     -     -   -    -
    |     |     |   |    |
    |     |     |   |    +----- day of week (0 - 6) (Sunday=0)
    |     |     |   +------- month (1 - 12)
    |     |     +--------- day of month (1 - 31)
    |     +----------- hour (0 - 23)
    +------------- min (0 - 59)
    

    Shamelessly stolen from: http://adminschoice.com/crontab-quick-reference

提交回复
热议问题