Date: Sun, 24 May 2009 13:46:35 +1000 From: GT <catch.all@marketmentat.com> To: freebsd-questions@freebsd.org Subject: Crontab for different ime zones Message-ID: <1243136795.29198.42.camel@ubuntu>
next in thread | raw e-mail | index | archive | help
Late entry to this thread, but... I thought I had found an answer to this; at present I think I might have been mistaken. My crontab has about a dozen jobs that need to run in TZ=America/New_York, and another dozen that ideally want TZ=Australia/Sydney... the server default is America/Chicago. Given that the DST wobble for Australia/Sydney is not the same as for America/New_York (and given that I am lazy) I wanted ONE crontab that would serve year-round, rather than FOUR crontabs that had to be swapped in and out all the time (even if that could be done by a cron job). I thought I had found a solution - simply insert a line TZ=America/New_York before the US jobs, and TZ=Australia/Sydney before the Australian ones. A final statement to return TZ to sever default would be optional. I checked that TZ changes worked, by adding a cron job (for testing purposes) under each TZ declaration, of the form TZ=America/New_York * * * * * date >> /home/mysite/public_html/tmp/log.txt 2>&1 and TZ=Australia/Sydney * * * * * date >> /home/mysite/public_html/tmp/log.txt 2>&1 Sure enough, every minute, cron would dutifully change TZ to NY and change again to Sydney. There would be two datestamps in log.txt - one would show current US/NY time, one would show current Australia/Sydney time. Oddly they would appear in REVERSE order in the output file (Sydney first, then NY). PROBLEM: If I run a very simple PHP script after each TZ declaration - for example, one that writes date("Y-m-d H:i e") to the same log file - the PHP script returns the server default timestamp (US/Chicago). So the script does not 'see' the TZ (that is not a problem since my work scripts don't have any internal time dependencies - the only time dependency is the START time). Also, if I time the script as if cron is actually 'seeing' Sydney time, the scripts don't execute as expected. Example: it is currently 1:45 pm Sydney time. If I change TZ=Australia/Sydney * * * * * date >> /home/mysite/public_html/tmp/log.txt 2>&1 to TZ=Australia/Sydney * 13 * * * date >> /home/mysite/public_html/tmp/log.txt 2>&1 cron will NOT run the script... I bet it will wait until 13:00 CHICAGO time. I have a feeling that I am missing something relatively simple - at which point my dream of a super-cron will be realised and the stupidity of DST can be ignored (as it ought to be... ). I also bet that someone else has worked this out already, somewhere in the internets tubes... but i have been unable to find it.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1243136795.29198.42.camel>