[英]Rails, Rake scheduled tasks and DateTime with config.time_zone on Heroku
I seem to always struggle understanding this... 我似乎总是很难理解这一点...
I have the Heroku scheduler running every 10m looking for new scheduled jobs to be run but it is not running when I expect it to - the difference is the time zone but I'm unclear exactly how I should do the comparison so it works the way I expect. 我让Heroku调度程序每10m运行一次,以寻找要运行的新调度作业,但我期望的时候它没有运行-时区不同,但是我不清楚我应该如何进行比较,因此它无法正常工作我预计。
in the rake task we have: 在rake任务中,我们有:
schedules = Schedule.where('status in (?) and next_run < ?', ['new', nil, ''], DateTime.current)
in application.rb is 在application.rb中是
config.time_zone = 'Auckland'
config.active_record.default_timezone = :local
Now, the exact example I have just seen that didn't do what was expected was this: 现在,我刚刚看到的并没有达到预期效果的确切示例是:
Difference is the +13 hours for the NZ time zone. 差异是NZ时区+13小时。
Question is, how should I do this comparison to get the schedule to fire when I am expecting? 问题是,我应该如何进行比较以使计划如期启动?
UPDATE 1: So after a bit of messing about, a few specific items worked for me: 更新1:在经过一番混乱之后,一些特定的项目对我有用:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.