Operating System - HP-UX
1833184 Members
3253 Online
110051 Solutions
New Discussion

allowable settings for /etc/default/tz

 
SOLVED
Go to solution
Raynald Boucher
Super Advisor

allowable settings for /etc/default/tz

Hello all,

What are the allowable settings for /etc/default/tz or $TZ?

I would assume any setting defined in /usr/lib/tztab but the following leaves me puzzled.

/etc/default/tz is set to "AST4ADT#Canada" but I get different results after varying TZ:
The date command returns a time 3 hours ahead after setting TZ to "Canada/Atlantic" which is not listed in /usr/lib/tztab. I would think that date used the default EST5EDT (but I can't figure the difference in hours).
On the other hand, the date command returns a correct time when TZ is set at "Etc/GMT+3" which is also not listed in /usr/lib/tztab.

here is the actual output:
$ cat /etc/default/tz
AST4ADT#Canada
$ date
Tue Jul 28 11:20:58 Etc/GMT 2009
$ TZ=Canada/Atlantic
$ date
Tue Jul 28 14:21:26 Canada/Atlantic 2009
$ TZ=AST4ADT#Canada
$ date
Tue Jul 28 11:22:38 ADT#Canada 2009
$ TZ=Etc/GMT+3
$ date
Tue Jul 28 11:35:05 Etc/GMT 2009
$

So where can I find all the allowable values.

Thanks
RayB
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: allowable settings for /etc/default/tz

Shalom RayB,

http://www.docs.hp.com/en/B2355-60130/security.4.html

Try man /etc/default/tz

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Matti_Kurkela
Honored Contributor
Solution

Re: allowable settings for /etc/default/tz

HP-UX does not use "Continent/Capital" style timezone definitions.

The format of /etc/default/tz is exactly the same as with the /etc/TIMEZONE file, but without the "TZ=" prefix.

/etc/TIMEZONE is just a one-line shell script that sets the TZ environment variable to the desired value.

The TZ variable overrides /etc/default/timezone, if both are set.

The full syntax of the TZ environment variable (and therefore also the syntax of /etc/TIMEZONE and /etc/default/tz) is described in "man environ".

The basic structure of the TZ value is
[DST_id]

The # sign and anything after that is a comment in the tztab file, and should not be included in the actual timezone setting. If you include it, it just makes the timezone identifier look ugly when the DST is in effect.

The timezone ID and the optional DST ID must be at least three characters long, but may be longer.

The UTC offset is defined in the POSIX standards as "the value you must add to the local time to get the UTC time". This is written so that the sign of the value becomes positive in North America, but it makes the sign work in a counter-intuitive way.

If your timezone does not use Daylight Saving Time, you are free to invent your own timezone ID if necessary. In that case, the timezone ID has no special meaning to the system: the system only cares about the UTC offset.

But if your timezone uses DST, then the entire TZ value (the combination of timezone ID, UTC offset and DST ID) must match one of the DST rule sets specified in /usr/lib/tztab.

If you need DST and there is no suitable DST rule set for your timezone in /usr/lib/tztab, feel free to read "man tztab" and write your own.

In your original situation, you show that /etc/default/tz is "AST4ADT#Canada", but I guess the TZ environment variable is also set to TZ=Etc/GMT+3 and it overrides /etc/default/tz.

When you set TZ=Canada/Atlantic, it apparently gets interpreted as UTC offset of zero, as there is no number at all in the TZ value.

TZ=AST4ADT#Canada apparently matches the tztab definitions, because it causes the difference of 3 hours, not 4. The system recognized that DST should be in effect and shifted the offset by one hour.

TZ=Etc/GMT+3 is a counter-intuitive one: it says the name of the timezone is "Etc/GMT" (which would mean essentially equivalent to UTC, right?) but "+3" means "add 3 hours to local time to get UTC", so the human-readable timezone definition would actually be "UTC-3 hours".

MK
MK
Dennis Handly
Acclaimed Contributor

Re: allowable settings for /etc/default/tz

>I would assume any setting defined in /usr/lib/tztab

Right, see tztab(4).

Why do you care about /etc/default/tz? TZ should always be set either by /etc/TIMEZONE or each user's .profile.

If your timezone doesn't have DST, you can make your own timezones. Seen environ(5) and TZ.

>I get different results after varying TZ:

If you set TZ, it doesn't look at /etc/default/tz.

>The date command returns a time 3 hours ahead after setting TZ to "Canada/Atlantic" which is not listed in /usr/lib/tztab.

tzset(3) says it uses UTC, when you have garbage input.

>MK: TZ=Etc/GMT+3 is a counter-intuitive one: it says the name of the timezone is "Etc/GMT" (which would mean essentially equivalent to UTC, right?)

Right, you shouldn't use GMT in your timezone unless you are GMT0.
Raynald Boucher
Super Advisor

Re: allowable settings for /etc/default/tz

OK,
I was wondering where timezone_id and DST_id were defined (or which values were allowed)... they are not, you define them yourself.

My problem started with the installation of an Oracle Enterprise Manager agent.
For some reason, we couldn't get it running using TZ=AST4ADT#Canada which is our system setting. We use Etc/GMT+3 in the user profile as a workaround but will probably have to change it come fall due to DST switch.
Oracle does support "Canada/Atlantic" but we get error messages for "invalid offset between the agent and repository" when we try to use it in the agent configuration.

I'll pursue Oracle for a permanent solution.

Thanks all

RayB
Raynald Boucher
Super Advisor

Re: allowable settings for /etc/default/tz

Thanks again