1830503 Members
2647 Online
110006 Solutions
New Discussion

Day Light Saving!

 
Amit Manna_6
Regular Advisor

Day Light Saving!

Hi,
Can anybody tell me how to check if Daylight savings is enabled or not on a HP server.
7 REPLIES 7
Hanwant Verma_1
Regular Advisor

Re: Day Light Saving!

The timezone is determined by reading the 'TZ' environment variable.

This variable is set when you execute 'set_parms timezone'. Set_parms
edits the file '/etc/TIMEZONE,' which exports the 'TZ' environment
variable. When you reboot after executing set_parms, the file
/etc/TIMEZONE will be read and your TZ variable set to the value you
specified. The value is in the format:

[:]STDoffset[DST[offset][,rule]]

For example: PST8PDT for the U.S. Pacific Time Zone

See the environ(5) manpage for a detailed description of the format.

Note, the offset for daylight savings time is supplied by the
'/usr/lib/tztab' configuration file.

libc functions like ctime use the 'TZ' variable to determine the
timezone.

Cheers
Hanwant Verma
Borislav Perkov
Respected Contributor

Re: Day Light Saving!

Hi Amit,
You have to see /etc/TIMEZONE like in my zone:

# more /etc/TIMEZONE
TZ=MET-1METDST
export TZ

As you can see the variable TZ has -1METDST which meens that DST is enabled when it occurs depending of the parameters for date when it changes in /etc/zoneinfo/MET. It should be same for your time zone.

Regards,
Borislav
Carlo Henrico_1
Regular Advisor

Re: Day Light Saving!

Kernel parameters "dst" should also be 1.
Type kmtune | grep dst

Quickest way to check!

Carlo
Live fast, die young - enjoy a good looking corpse!
A. Clay Stephenson
Acclaimed Contributor

Re: Day Light Saving!

In a very real sense, your system doesn't change time at all. It simply counts seconds since 1-Jan-1970. What does change is the way those seconds are displayed. The global TZ setting is controlled by /etc/TIMEZONE but that can be overriden by settings in a user's .profile simply setting and exporting TZ. To actually test your TZ (and to test if you have correctly set values in the tztab file), use the attached Perl script.

dst.pl -n will display the next time change. Invoke as dst.pl for full usage.

If it ain't broke, I can fix that.
Bill Hassell
Honored Contributor

Re: Day Light Saving!

As mentioned, HP-UX doesn't know anything about Daylight Saving Time. It keeps time as Clay mentioned based on GMT (or more accurately, UTC or Zulu time. By using a common library call to retrieve the time, the TZ variable can change way time is represented. The date command will display or change the time based of the current value of TZ. For the easiest explanation, look at the manpage for env. It will show you how you can make your own timezone.

By using a simple variable, each user can see their own timezone which is great for an international machine. A user inn Australia and a user in England can login to the same machine, yet see the time displayed in their own timezone - just set TZ appropriately in their login profile (typically .profile).

As far as whether your login will show the time change, tpye the command:

echo $TZ

If it has only a single timezone name (like GMT0) then no Daylight Saving will be observed. If it has the extension (like GMT0BST) then the rules for British time will be obsevered as defined in /usr/lib/tztab.

The file /etc/TIMEZONE provides a default TZ value in /etc/profile for all users, but this is just a default value and is most often set to match the timezone where the machine is located (ie, for the console). You can actually see the time in any timezone by temporarily defining a different timezone for the date command, like these examples:

TZ=EST5EDT date
TZ=PST8PDT date
TZ=GMT0 date

If you find that your particular timezone is not found in /usr/lib/tztab, don't worry. You can make your own timezone entry in tztab. Use the tztab comments and man page for tztab to help with this task.


Bill Hassell, sysadmin
Scott Lindstrom_2
Regular Advisor

Re: Day Light Saving!

Out of curiosity, has anyone ever used 'date -a' to slowly subtract one hour rather than have it fall back immediately?

We shut down our databases and apps for the time change in the fall; I wonder if this could easily be avoided by using the "Slowly adjust the time" feature instead.

Scott
Bill Hassell
Honored Contributor

Re: Day Light Saving!

It is definitely not a good idea to change the system time. date -a is designed to move a few minutes, although it's possible that the date command does not have any checks for a massively large change like 3600 seconds. NTP uses this technique (ntpdate -B) but is limited to 1024 seconds (17 minutes). Most modern databases run on GMT internally and rely on the OS libraries to translate the time to a local value for display.

The 'slow' adjustment is typically requires about as much as an hour per minute of change, so changing 60 minutes is not possible in less than one day. The whole point of slewing the time is that every time tick (all 86,400 seconds) will occur per 25 hour period, so the time between ticks is slightly adjusted to keep in sync with the master clock.


Bill Hassell, sysadmin