LoginSignup
2
1

More than 3 years have passed since last update.

ec2運用のrailsアプリでcronの実行時間がズレる

Posted at

ec2で運用のrailsアプリでcron使って定期的にプッシュ通知を送りたい。そこで以下のように書いてみる。

schedule = PeriodicNotification.where(status: 0).find_by("schedule_date <= ?", Time.now)

wheneverを使ってcron登録し運用してみたところutc時間で送られているようだ。以下のように直した。

schedule = PeriodicNotification.where(status: 0).find_by("schedule_date <= ?", Time.current)

Time.nowだと環境依存の時間、Time.currentだとアプリ依存の時間が取れるらしい。

以上。

2
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
2
1