如果 Heroku 服务器使用 UTC,如何在 PST 中设置调度程序 cron 时间?

How to set scheduler cron times in PST for Heroku servers given they use UTC?

由于 Heroku 运行 上的服务器采用 UTC 时间,您如何将 cron 时间设置为太平洋标准时间每天凌晨 3 点 运行?在推荐内置的 Heroku 调度程序之前,我想将所有内容都保留在 Resque 中。此外,将服务器时间保留为 UTC 会很酷。

ImportClass:
  description: 'Import Class'
  custom_job_class: 'Class::ImportClass'
  cron: '0 3 * * *'
  queue: high

如果您愿意,可以通过 Heroku 仪表板添加 TZ ENV 变量。打开您应用的仪表板并导航到 'settings' 选项卡,然后在 'config variables' 下单击 'reveal config vars' 按钮。然后您将能够添加 TZ = America/Chicago (或您需要的任何时区)。

然后相应地设置 cron

仅供参考:可用 tz 区域列表为 https://en.m.wikipedia.org/wiki/List_of_tz_database_time_zones