Crontab for different ime zones

GT catch.all at
Sun May 24 23:31:18 UTC 2009

On Sat, 2009-05-23 at 23:41 -0600, Tim Judd wrote:

> <SNIP>
> I propose the following:
>   cron itself has no concept of timezone.  it is 'date' that is picking up
> TZ and reporting as such.  Cron's job is so simple is that it wakes up each
> minute to see if it has work to do, regardless of timezone, or anything
> else.

Yep - I understood that, Tim. 

Thew issue seems to be that cron pays no attention to TZ declarations
that happen AFTER it wakes up - cron does not parse the job times using
the new TZ.

The thing I am struggling with is that 'date' picks up the changes
imposed by 'TZ=', but then 'cron' parses the next line as if the job
times are interpreted using the server's default TZ.

I've tried using 'CRON_TZ=' as well as, and instead of, 'TZ=' - to no

What I thought ought to happen is this:

*  'cron' wakes up;
*  'cron' works through the crontab line by line;
*  at line 1 cron changes the TZ to America/NY;
*  at line 2 cron reads the job time in the context of having just been
told that it's operating in the NY timezone (thus 45 13 * * * is 1:45 pm
NY time);
* at line 15 cron is told to change the TZ to Australia/Sydney;
* from line 14 onwards, 45 13 * * * is 1:45 pm SYDNEY time.
and so on.

It seems that cron behaves as if it forgets $TZ at each newline within a
given cron instance. 

The silly thing is, with all the time I've wasted pursuing this wild
goose I could have built the required four crontabs, and written the
script to swap them in and out on the appropriate dates.

(Or I could have spent $100 and bought a shared-hosted server space to
do the Australian-TZ stuff and given it sufficent permission to store
the resultant data in y primary mySQL db...)

Still, I think it's worth persevering with. I'm certain it can be done.

> You might want to try some other determining factor, such as a shell
> builtin.
> Good luck.


> _______________________________________________
> freebsd-questions at mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at"

More information about the freebsd-questions mailing list