System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup timezone with NO clock changes

 
SOLVED
Go to solution
Ken Englander
Regular Advisor

How to setup timezone with NO clock changes

Egypt has decided not to change the clock at all, at least for the time being. So, no DST. I am trying to understand what is the best way to do this. The system is running HP-UX 11i v3. They currently have the following custom entries in /usr/lib/tztab.

#Custom Time zone CAT-2CATDT for Cairo - NK018559
CAT-2CATDT
0 1 24 4 2009 0-6 CATDT-3
0 23 20 8 2009 0-6 CAT-2
0 1 24 4 2010 0-6 CATDT-3
0 23 20 8 2010 0-6 CAT-2

Clearly changing the last two entries is one option. I would just change the last two lines as follows.

0 1 24 4 2010-2038 0-6 CAT-2
0 23 20 8 2010-2038 0-6 CAT-2

In discussions with other associates at my company, it has been suggested that it would be better to create a new timezone. I must say I do not fully understand why others have suggested that option, but I wanted to solicit input from this group about it.

I got some good info from the following thread already, but it does bring one question to mind. The timezone is in /etc/TIMEZONE and /etc/default/tz. Is it only necessary to change /etc/TIMEZONE?

http://h30499.www3.hp.com/t5/System-Administration/HP-UX-time-setting/m-p/4774412#M390323


So - what if I wanted to set up a new timezone that never changes? I do not know if there is a predefined timezone for Cairo - I did not see one in /usr/lib/tztab. Assuming there is nothing suitable, what is the proper way to create a new timezone? If it never changes does that mean there does not need to be anything in /usr/lib/tztab?

Thanks!

9 REPLIES
Solution

Re: How to setup timezone with NO clock changes

>I am trying to understand what is the best way to do this.

Probably a new timezone.

>I would just change the last two lines as follows.
0 1 24 4 2010-2038 0-6 CAT-2
0 23 20 8 2010-2038 0-6 CAT-2

You can't do this because you would change an existing 2010. You would need to add two lines for 2011 and on.
Or perhaps you don't have an entry for 2011?

>what if I wanted to set up a new timezone that never changes?

Easy: TZ=CAT-2

>what is the proper way to create a new timezone? If it never changes does that mean there does not need to be anything in /usr/lib/tztab?

Just export TZ in a .profile or edit /etc/TIMEZONE and /etc/default/tz.
Right, you don't need a tztab(4) entry.
Matti_Kurkela
Honored Contributor

Re: How to setup timezone with NO clock changes

Looks like your current custom /usr/lib/tztab entry does not specify any DST transitions for year 2011, so no automatic DST transition should happen this year (nor on any future years, unless the tztab file is updated). So you won't have to do anything at all.

"Creating a new timezone" sounds a bit like a Windowsism. On Windows, the timezone information is stored in a rather opaque way, so you cannot even verify any future DST transitions without . As a result, creating a new timezone with an unique name makes it easier to later confirm that the correct configuration change is in fact applied - on Windows.
(See http://support.microsoft.com/kb/914387 if you're curious.)

On HP-UX, all the timezone information is in /usr/lib/tztab whose format is documented and human-readable without any conversion. It's not too difficult to check the value of the TZ environment variable and then read the appropriate /usr/lib/tztab entry: once you've done that, you will know the times of any past and future DST transitions with 100% certainty.

Remember that on Unix, all the system timestamps are internally stored in UTC-equivalent form, and converted to your local time (using the currently-configured timezone settings) on output. So, if you change your timezone setting to "CAT-2", the system will assume that there is no DST _and never has been_, so e.g. the timestamps of files last modified on June 2010 will seem to be 1 hour off when viewed with "ll". The timestamps will still contain the correct information in UTC timezone, but with the "CAT-2" setting, the conversion to local time will stop taking into account that DST _was_ used in 2010.

If you don't care about the accuracy of old timestamps, you can certainly change the timezone setting to "CAT-2". If you do so, this TZ setting will contain all the information the system needs for basic local time support: the timezone name "CAT" and the UTC offset "-2". If there is no DST timezone suffix, then the /usr/lib/tztab file will not be used at all.

If you choose to make any changes, you should change both /etc/TIMEZONE and /etc/default/tz.

Historically, HP-UX used to have timezone settings as kernel parameters "timezone" and "dst": this was deprecated long ago, and is currently used mainly by some legacy PA-RISC applications. HP-UX 11iv3 still has these kernel parameters, but they might finally go away in 11iv4 as the PA-RISC support ends.

/etc/TIMEZONE used to be the "current" way to configure the timezone in the previous 10.20...11.xx releases.

/etc/default/tz was introduced in some 11i release (maybe 11iv2, I think?), so in the future this will perhaps be the "primary" way to set the timezone.

MK
MK
Ken Englander
Regular Advisor

Re: How to setup timezone with NO clock changes

WOW - thank you both for the input!

Forgive my mistake - I'm usually pretty good about remembering the new year when it changes, but for some reason I was thinking the current /usr/lib/tztab had entries for the current year, 2011, when I was thinking about modifying the 2010 entries. That is not what I meant to do.
Ken Englander
Regular Advisor

Re: How to setup timezone with NO clock changes

OK, so the bottom line from my associates is that we need a new timezone because of other applications that connect to the HP-UX system.

It looks like all I need to do is set it up in /etc/default/tz and /etc/TIMEZONE. I just ran a test where I put the string "EGT-2" in these files and rebooted. I did not put anything in /usr/lib/tztab.

Does this sound correct?

Re: How to setup timezone with NO clock changes

>I just ran a test where I put the string "EGT-2" in these files and rebooted. I did not put anything in /usr/lib/tztab.
>Does this sound correct?

Sounds fine.

Re: How to setup timezone with NO clock changes

>we need a new timezone because of other applications that connect to the HP-UX system.

Note: You can have multiple timezones on the system. One for operations and even one for specific users of that application.
Just "export TZ" in the appropriate .profile.
In this case you don't have to reboot.
Ken Englander
Regular Advisor

Re: How to setup timezone with NO clock changes

> Note: You can have multiple timezones on the system. One for operations and even one for specific users of that application.

YIKES - I don't think I would want to do that unless it was simply for testing something. Sounds very dangerous as a way to do things.

I am recommending a reboot to make certain that all applications use the new timezone.

Thanks again for the help!
James R. Ferguson
Acclaimed Contributor

Re: How to setup timezone with NO clock changes

Hi Ken:

> YIKES - I don't think I would want to do that unless it was simply for testing something. Sounds very dangerous as a way to do things.

That's absolutely not true. Unix (and NTP) work in UTC. The concept of a timezone is simply the +- offset in which *you* like to measure time.

The underlying clock ticks away in ever-advancing seconds (oh, yes, for the most part) -- one second since January 1, 1970 at 00:00:00 UTC.

Your perception of that Epoch may be slightly earlier or slightly later in your localtime, but the fundamental value remains the same.

Regards!

...JRF...
Ken Englander
Regular Advisor

Re: How to setup timezone with NO clock changes

I would have to disagree, especially when you consider my company deals with the medical industry, so misinterpreting a time could be very critical.

It is what I would call "slick" but not easily maintainable, hence in my opinion NOT a good practice. Not all time is recorded in UTC in the applications, so it is less relevant what is going on at the OS level.

So, we must agree to disagree!