Talk:Crontab

It is supposed to be possible to change the timezone (as seen by cron) from within the crontab; if the server TZ is, say, CDT, cron's TZ can be changed by a line

 

To verify that this works, simply add a cron job immediately after it...  

you will find that log.txt does in fact show a timestamp for the timezone you chaged to using 'TZ='.

That said, there is a big issue with it, to which I have been unable to find a solution on the internets tubes.

The problems are besrt illustrated by an example.

My example: I have a crontab that runs a dozen or so jobs that depend on US/NY time, and another dozen that depends on Australia/Sydney time.

Different timezones move to and from daylight savings at different times, so I wanted ONE crontab that served year-round, rather than 4 different crons that I had to remember to swap out on the appropriate dates. Thus CRON_TZ seemed perfect.

BUT...if I do

 

each of the 'TimeCheck_XX.php' (XX in [US, AU]) scripts are simply

 

The problems that arise:

(1) unreliability of output - the log.txt file shows that the Auastralian timestamp gets written to log,txt BEFORE the US datestamp despite appearing AFTER it in the crontab. The output from the two TimeCheck scripts are BOTH appended AFTER the output of the two date jobs (you would expect date, TimeCheck_US, date, TimeCheck_AU);

(2) no change to the PHP timestamp - the two 'TimeCheck' php files both report the default (CDT) time;

(3) cron seems to ignore the new timezone despite printing it to file (e.g., if the time in Australia is known to be 11:05 a.m., and the date and TimeCheck_AU.php cronjobs are changed to * 11 * * *, NOTHING HAPPENS.


 * Please ask questions in a forum. --ThorstenStaerk 07:16, May 24, 2009 (UTC)