Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 May 2009 09:31:01 +1000
From:      GT <catch.all@marketmentat.com>
To:        Tim Judd <tajudd@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Crontab for different ime zones
Message-ID:  <1243207862.11905.0.camel@ubuntu>
In-Reply-To: <ade45ae90905232241g5d17d9ccnb19bdd164a6252d@mail.gmail.com>
References:  <1243136795.29198.42.camel@ubuntu> <ade45ae90905232241g5d17d9ccnb19bdd164a6252d@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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
avail.


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.

Cheers

> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1243207862.11905.0.camel>