2
1

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.

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

2
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?