harrystech/cronut

Once-a-day cron jobs appear to have time zone problems

Closed this issue · 2 comments

I have the following issue with cron jobs run once a day:

When I save the job, the next scheduled time appears in EDT time, but I have to save the job with a cron expression written in UTC time (so a job at noon would be * 16 * * *). That's no big deal (and may be preferable), but when the job gets pinged, the verification / next scheduled time-setting behavior appears to be four hours off (I'm in EST/EDT, so the mismatch is the same as the offset from UTC).

The specs test for a cron job that is running every ten minutes, so if Harry's is never running once-a-day jobs, I can see how this might be broken. I'm happy to write a PR with specific tests and a fix (if it is indeed broken), but in order to not generate any new compatibility problems with existing users of Cronut, I have a couple questions:

  1. Are cron expressions in Cronut meant to be expressed in UTC or the local time zone?
  2. Is Harry's currently using any cron jobs that are only run once a day? If so, can you show me an example from your setup? I have a job I've been executing daily at EST midnight, and it either fails for being run too early (if I write the cron as UTC), or it fails for being run too late (if I write the cron as EST and ignore the returned time in the interface).

Cronut currently relies on rufus-scheduler to parse cron-lines. We find that the timezone it is interpreted (whether local or UTC) can vary from system to system based on its time config. But thankfully, one of the reasons we used rufus-scheduler over other implementations is that it supports time zones in cron-lines. In our setup, we always specify the time zones, for instance a job that runs at 1am EST/EDT daily is 00 1 * * * America/New_York and it has worked for us. I'm wondering if there is perhaps a bug that occurs when the a job has a different time zone than the Cronut config.

@blahblahblah-, specifying the time zone explicitly fixed the issues for me. I'm going to do a PR to add a note to the docs.