21
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Heroku Scheduler で月一回だけ実行したい

Last updated at Posted at 2015-02-14

概要

Heroku Scheduler でバッチを月一回だけ(あるいは週一回だけ)実行したい
bashifで日付指定する。

[ $(date +%d) = 01 ] && ruby ./batch.rb #毎初日に実行

準備

dyno のタイムゾーンを東京にしておく

heroku config:add TZ=Asia/Tokyo

Heroku Scheduler Add Job... で追加
task 欄にシェルスクリプトで条件と実行するバッチを設定
FrequencyDaily
Next Runここでの表示時間は UTC なので 00:00 に実行したい場合は -9hr して 15:00 で設定

そのほか

[ $(date +%u) = 1 ] && ruby ./batch.rb #毎月曜日に実行
[ $(date +%m) = 02 ] && [ $(date +%d) = 14 ] && ruby ./batch.rb #2/14に実行
21
19
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
21
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?