1832224 Members
2347 Online
110041 Solutions
New Discussion

daylight saving time

 
SOLVED
Go to solution
chad_c
Super Advisor

daylight saving time

how do i ensure my HPUX 11.11i servers are set to auto adjust for daylight saving time?
11 REPLIES 11
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: daylight saving time

Run the attached Perl script, dst.pl. Invoke as dst.pl -u for full usage but you can simply run as "dst.pl" to display the exact second before and after the transition. If you are running multiple TZ's then test it thusly:

TZ=EST5EDT dst.pl
TZ=CST6CDT dst.pl
TZ=MST7MDT dst.pl

You many need to change to "shebang" line from #!/usr/bin/perl to something like "#!/opt/perl5/bin/perl" or create a softlink from your perl install bin to /usr/bin/perl.

Because this Perl scripts uses the same underlying libc functions as do the standard commands like date, if this work then the other utilities work as well.
If it ain't broke, I can fix that.
chad_c
Super Advisor

Re: daylight saving time

does the script just verify that the time is adjusted accordingly?
A. Clay Stephenson
Acclaimed Contributor

Re: daylight saving time

What it actually does is find the very first and last seconds in a given year. It then converges on the exact seconds that the localtime() isdst field changes. When those transition points are found strftime() is called to display seconds - 1 and seconds for each transition.

The bottom line it that this is a method that uses the same standard routines that UNIX commands and programs use -- so if this works and displays the expected times then the others also work when that time comes.

Bear in mind that your UNIX box does not actually change time; it simply counts seconds since 00:00:00 1-Jan-1970 UTC. What changes is the way these epoch seconds are displayed. HP-UX is unique in that the time transitions are controlled by a textfile, /usr/lib/tztab. Man tztab for details.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: daylight saving time

By the way, if you happen to have TZ settings that do not change (either by intent or accident) then dst.pl returns a null result and sets the exit code to a non-zero value.

e.g.

TZ=GMT0 dst.pl -d
STAT=${?}
echo "Status = ${STAT}"

If it ain't broke, I can fix that.
chad_c
Super Advisor

Re: daylight saving time

so in other words if i see the following output, then the server is going to auto adjust according to daylight saving :)

txovo# perl /tmp/tz.pl
Sun Apr 02 01:59:59 CST 2006 --> Sun Apr 02 03:00:00 CDT 2006
Sun Oct 29 01:59:59 CDT 2006 --> Sun Oct 29 01:00:00 CST 2006
chad_c
Super Advisor

Re: daylight saving time

so in other words if i see the following output, then the server is going to auto adjust (or i should say 'accurately reflect') according to daylight saving :)

txovo# perl /tmp/tz.pl
Sun Apr 02 01:59:59 CST 2006 --> Sun Apr 02 03:00:00 CDT 2006
Sun Oct 29 01:59:59 CDT 2006 --> Sun Oct 29 01:00:00 CST 2006
Steven E. Protter
Exalted Contributor

Re: daylight saving time

Shalom chad,

Answer to last question: Yes.

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
A. Clay Stephenson
Acclaimed Contributor

Re: daylight saving time

Does a hog like slop? Is the Pope Catholic?
If it ain't broke, I can fix that.
chad_c
Super Advisor

Re: daylight saving time

someone always has to be a smart A$$
chad_c
Super Advisor

Re: daylight saving time

however, to answer your question as to whether a hog likes slop, you may have to go and ask the pope

thanks for the info.
A. Clay Stephenson
Acclaimed Contributor

Re: daylight saving time

No, having slopped hogs at an early age, I can assure you that they eat it (and generally anything else) with great relish.
If it ain't broke, I can fix that.