LoginSignup
1
1

More than 1 year has passed since last update.

sidekiq-scheduler cronの実行時間指定方法

Posted at
  • Sidekiq schedulerで「Cron」を使って実行時間を指定します。

config/sidekiq_scheduler.yml

:schedule:
  hello_world:
    cron: '*/30 * * * *' # every 30 minutes
    class: 'HelloWorld'
    queue: single
    description: 'Test'
  • 基準はパラメタ5つを使って実行時間を指定します。
    Minutes Hours Days Months DayOfWeek
    例:
    スクリーンショット 2023-03-03 15.23.57.png
'1 * * * *'         # execute at 1 minute of every hour, ex: 12:01, 13:01, 14:01, ...
'0 0 * * *'         # Every day at midnight (毎日 00:00に実行)
'5 0 * * *'         # Every day after midnight (毎日 0時05分に実行)
'0 5 * * *'         # Every day at 5am (毎日 5時AMに実行)
'0 17 * * *'        # Every day at 5pm (毎日 5時PMに実行)
'0 /3 * * *'        # every 3 hours (3時間毎に実行)
'0 22 * * 1-5'      # at 22:00 on weekdays(週日朝22時に実行)
'0 17 * * 2'        # every tuesday at 5 pm (毎週火曜日午後5時に実行)
'0 17 * * 1,2'      # every tuesday and monday at 5 pm (毎週火曜日と月曜日午後5時に実行)
'15 14 1 * *'       # at 14:15 on the 1st of every month
'0 5 1-7 * 1'       # 05:00 on the first Monday of the month
  • 秒毎に実行したいときは、「パラメタ6つ」を使います。
    Seconds Minutes Hours Days Months DayOfWeek
    スクリーンショット 2023-03-03 15.29.44.png
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1