Skip to content

Mutliple time zones for cron

January 23, 2007

I’ve never worked out why things happen in pairs but last Friday two timezone related issues came up. One a server running in some US timezone while serving services to all the world prompted my blog entry to suggest that you run your servers in GMT post. However there was also a question about cron, which featured in the follow up to my post. That is cron run in the timezone of the system. Not the timezone of the users or a arbitrary timezone chosen by the user. Would it not be cool to be able to specify a timezone in your crontab file? Better yet let you specify multiple timezones in crontab files eg: z

TZ=US/Pacific * 11 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out * 19 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out19 * 15 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out15 * 8 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out8 TZ=GMT * 15 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out15gmt


So the first four crontab lines would run in US/Pacific and the last in GMT. Each user can use as many timezones as they wish and the TZ environment variable is propergated to the child.


Now as it happens I am travelling so that has meant a few hours in Airports and I got wondering how easy it would be to get cron to be more timezone friendly.

The answer to this is it takes just over one Tecra M2 battery life to get it working. Clearly this needs some more testing , and the crontab command needs to validate the TZ strings rather than just past them though. but the diffs are here. The output file shows one of the runs from US/Pacific:

6 # cat /tmp/cron.out8 Tue Jan 23 08:25:00 PST 2007 Tue Jan 23 16:25:00 GMT 2007 7 # 

Now I need to file an RFE and see if this can be putback.

Tags: topic:[opensolaris] topic:[cron]

Advertisements

From → Solaris

Mutliple time zones for cron

January 23, 2007

I’ve never worked out why things happen in pairs but last Friday two timezone related issues came up. One a server running in some US timezone while serving services to all the world prompted my blog entry to suggest that you run your servers in GMT post. However there was also a question about cron, which featured in the follow up to my post. That is cron run in the timezone of the system. Not the timezone of the users or a arbitrary timezone chosen by the user. Would it not be cool to be able to specify a timezone in your crontab file? Better yet let you specify multiple timezones in crontab files eg: z

TZ=US/Pacific * 11 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out * 19 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out19 * 15 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out15 * 8 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out8 TZ=GMT * 15 * * * (/usr/bin/date ; /usr/bin/date -u) > /tmp/cron.out15gmt


So the first four crontab lines would run in US/Pacific and the last in GMT. Each user can use as many timezones as they wish and the TZ environment variable is propergated to the child.


Now as it happens I am travelling so that has meant a few hours in Airports and I got wondering how easy it would be to get cron to be more timezone friendly.

The answer to this is it takes just over one Tecra M2 battery life to get it working. Clearly this needs some more testing , and the crontab command needs to validate the TZ strings rather than just past them though. but the diffs are here. The output file shows one of the runs from US/Pacific:

6 # cat /tmp/cron.out8 Tue Jan 23 08:25:00 PST 2007 Tue Jan 23 16:25:00 GMT 2007 7 # 

Now I need to file an RFE and see if this can be putback.

Tags: topic:[opensolaris] topic:[cron]

From → Solaris

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: