Search code examples
ruby-on-railsherokucronresqueresque-scheduler

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


Since servers on Heroku run under UTC time, how do you set the cron time to run at 3am PST daily? Before you recommend the built in Heroku scheduler, I would like to keep everything inside of Resque. Also, it would be cool to leave the server time as UTC.

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

Solution

  • The TZ ENV variable can be added via the Heroku dashboard if you prefer. Open your app's dashboard and navigate to the 'settings' tab, then under 'config variables' click the 'reveal config vars' button. You will then be able to add TZ = America/Chicago (or whatever timezone you need).

    Then set the cron accordingly

    FYI: List of available tz zones are https://en.m.wikipedia.org/wiki/List_of_tz_database_time_zones