LoginSignup
5
4

More than 5 years have passed since last update.

Heroku Schedulerの設定がUTCだったのでHerokuのTimeZoneをJSTに変更してもかわらなかったお話

Posted at

タイトルがそのまま結論なんですが。。。
Scheduler=cronだろうという安易な考えでHerokuのタイムゾーン変更しました。
結果はタイトルの通りで何も生産していませんが、、

Scheduler入れる

$ heroku addons:add scheduler:standard 

Schedulerの設定画面を開く

$ heroku addons:open scheduler

Open_Heroku_Scheduler.png

ここで、JSTじゃなくてUTCなんだーと気付く。
タイムゾーン変更したら反映されるのではと?←
ほぼ!ほぼ!無理だろう と思いつつ
試してみることに。

自分の環境確認

$ rails c
Loading development environment (Rails 4.0.2)
[1] pry(main)> Time.now                                                                                                                                                                   
=> 2014-03-08 12:39:34 +0900
[2] pry(main)> exit                   

Herokuの環境確認

$ heroku run console
Running `console` attached to terminal... up, run.6407
Loading production environment (Rails 4.0.2)
irb(main):001:0> Time.now
=> 2014-03-08 03:40:34 +0000
irb(main):002:0> exit

HerokuのTimeZone変更

$ heroku config:add TZ=Asia/Tokyo
Setting config vars and restarting kimatakubot... done, v12
TZ: Asia/Tokyo

Herokuの環境確認

$ heroku run console
Running `console` attached to terminal... up, run.9850
Loading production environment (Rails 4.0.2)
irb(main):001:0> Time.now
=> 2014-03-08 12:41:42 +0900
irb(main):002:0> exit

Heroku logで確認

$ heroku logs
2014-03-14T00:00:41.942770+00:00 heroku[api]: Starting process with command `bundle exec rake XXXX` by scheduler@addons.heroku.com
2014-03-14T00:00:46.491058+00:00 heroku[scheduler.XXXX]: Starting process with command `bundle exec rake XXXX`
2014-03-14T00:00:47.056171+00:00 heroku[scheduler.XXXX]: State changed from starting to up
2014-03-14T00:00:53.268497+00:00 heroku[scheduler.XXXX]: Process exited with status 0
2014-03-14T00:00:53.274715+00:00 heroku[scheduler.XXXX]: State changed from up to complete

まぁそうだろうなと思いながら結果をみたらやはりUTCのままでしたorz
※ このlogとconsoleで日付が全然違いますが動作確認はその場で取っております

5
4
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
5
4