Roland, Thanks for bringing this to my attention. Chris, The format shown in http://blogs.sun.com/chrisg/entry/mutliple_time_zones_for_cron is not allowed by the current standards. The standards say that entries in crontab files are of three types: 1. Blank lines (i.e., spaces and tabs only terminated by a newline) 2. Comment lines (i.e., lines whose first non-blank character is '#') 3. The standard 6 field crontab entry specifying the minute, hour, day of month, month of year, day of week, and command to be executed by the shell. So, lines like: TZ=GMT and TZ=US/Pacific are not allowed. But, since lines like: # TZ=GMT and # TZ=US/Pacific are allowed by the standard, you can do the same thing in a manner compatible with the standard. For the record, I have also seen suggestions lately that $SHELL should affect the shell used to run cron jobs. The standard also says that this is not allowed. The values of $HOME, $LOGNAME, $PATH, $SHELL and, although not explicitly mentioned, $TZ in the environment inherited by crontab are not allowed to be used by default. But this can be done and still meet standards requirements by using implementation specific extensions such as command line options. I.e., the standard allows for option to be specified when crontab is invoked to add a cron job. So, something like: crontab [-H HOME_value] [-L LOGNAME_value] \ [-P PATH_value] [-S SHELL_value] \ [-T TZ_value] [file] would be legal and the values specified could be stored as comments in the crontab file. Note also that a lot of this can be done today with no changes to cron or crontab. You can set TZ in the environment of the command to be executed using the following form: * 8 * * * TZ=US/Eastern date > /tmp/out8 which will write a date stamp to the console every minute of the 8 o'clock hour of the local timezone displayed with US Eastern Time Zone time stamps. It is trickier when using subshells as in your example where you would have to use: * 8 * * * TZ=US/Eastern;export TZ;(/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out8 if you're using /usr/bin/crontab to add the job. /usr/bin/crontab uses a SVID3 compatible shell which does not support variable assignment in an export statement. If you're using /usr/xpg4/bin/crontab or /usr/xpg6/bin/crontab, the same crontab entry could be written as: * 8 * * * export TZ=US/Eastern;(/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out8 Whether you would want to use this form obviously depends on whether you want the time at which the command will be executed and the output of commands run to be controlled by the alternate TZ setting, or you just want the output of the commands run to be controlled by the alternate TZ setting.
Cheers, Don >Return-Path: <roland.mainz at nrubsig.org> >Date: Sat, 10 Feb 2007 00:57:00 +0100 >From: Roland Mainz <roland.mainz at nrubsig.org> >Subject: Re: [request-sponsor] request sponsor for 6518038: cron & crontabshould support multiple timezones >To: Darren J Moffat <Darren.Moffat at sun.com> >Cc: Chris Gerhard <chris at thegerhards.com>, request-sponsor at >opensolaris.org, Don Cragun <don.cragun at sun.com> >MIME-version: 1.0 >Content-transfer-encoding: 7BIT >X-Accept-Language: en >X-PMX-Version: 5.2.0.264296 > >Darren J Moffat wrote: >> Chris Gerhard wrote: >> > I have a working prototype which I have documented here: >> > >> > http://blogs.sun.com/chrisg/entry/mutliple_time_zones_for_cron >> > >> > Since this is not part of my day job, I'm requesting a sponsor despite >> > being a Sun employee so I can do this on my own time. >> >> Chris is local to me (physically and timezone :-) I hope that we can >> present the full process at a future LOSUG and given this needs ARC >> review I'll sponsor the ARC case and the putback for this. > >Two items: >1. Is it possible to sync with the POSIX people whether the change is >legal for XPG4/XPG6, please (CC:'ing Don Cragun for that) ? >2. Somewhere in my queue is support for sub-minute timing in cron... >would it be usefull to add this in one step with this patch, too ? > >---- > >Bye, >Roland > >-- > __ . . __ > (o.\ \/ /.o) roland.mainz at nrubsig.org > \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer > /O /==\ O\ TEL +49 641 7950090 > (;O/ \/ \O;)