Operating System - HP-UX
1837578 Members
3131 Online
110117 Solutions
New Discussion

Re: Day light saving time

 
SOLVED
Go to solution
Peter Gillis
Super Advisor

Day light saving time

Hi, Ux 11.11 v1 ; RP2470

Can someone tell me if there is a quick check that can be run on a system to see when the daylight savings time is going to kick in? Wanted to check this out considering daylight savings (in NSW, AUSTRALIA) is going to be a week later than usual due to a recent government ruling for the commonwealth games over here.

thanks heaps
maria
16 REPLIES 16
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Day light saving time

Does a hog like slop? Run this Perl script, dst.pl.

You can invoke it as dst.pl -u for full usage but simply "dst.pl" will display the exact second before and after the time transition. You can check multiple TZ's by:

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

If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: Day light saving time

Oh, and because this Perl script uses the same underlying libc functions that the standard utilities like the date command use, if the Perl script works, everything that uses the standard functions will work as well.
If it ain't broke, I can fix that.
Steven E. Protter
Exalted Contributor

Re: Day light saving time

Shalom Maria,

In most normal time zones, if the Timezone is set, the time will change on schedule.

If your change is very recent, you may want to make sure you are up to date. There is a file you can use to override time zone changes. We have to use it to deal with the Knesset here not being able to agree year to year on the time switches.

Also, though its really slight of hand, if you are connected to an ntp server, you have nothing to worry about.

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
Peter Gillis
Super Advisor

Re: Day light saving time

Thanks Clay and Steven. Clay with the perl script, we dont actually have perl config'd so I will give that a go later today. Is that a big task? (yes, you are dealing with the really basic here!) You mention run the job with the TZ listed first...does that mean if the job is run without a tz listed it will ask for one during the running of the job?

Steven, what is the name of the file. I believe this is a quite recent change, that is why I am checking.

thanks again
Maria
Bill Hassell
Honored Contributor

Re: Day light saving time

The file that pre-defines timezones is called /usrf/lib/tztab and you'll find a good man page for it along with the comments in the file itself. NOTE: timezones (as you are probably well aware) are political, and only loosely based on the rotation of the earth. NTP is a great tool as it can maintain the only time kept in HP-UX (which is UTC, aka GMT) very accurately (to a fraction of one second). It cannot, however, do anything about timezones.

HP-UX uses a variable called TZ to define how to interpret UTC for a local user. The first place to start with timezones is the man page for environ (man environ). You'll see that you can use my own personal tiomezone called BILLH5:33:12 by doing something like this:

TZ=BILLH5:33:12 date

You'll see the time is displayed 5 hours, 33 mins and 12 seconds to the west of GMT and there is no Daylight Saving for summer. Of course, this is only an academic example, but shows that you can define any rule for a local timezone. Just set TZ as required.

The US (like Australia) is changing Daylight Saving rules (remember the part about politics?) so a patch for tztab has been released but since adding your own timezone rules is just a matter of editing tztab, just use the man pages for tztab and environ.

As far as Perl goes, you should have it already installed on your system. Check the version with perl -v (you need 5.xxxx to be current). Note that once you change tztab, the results are immediate. Although tricky to find (man date), if TZ is not set, you get this:

"If TZ is not set or is set to the empty string, its default value is EST5EDT."


Bill Hassell, sysadmin
A. Clay Stephenson
Acclaimed Contributor

Re: Day light saving time

As mentioned the file you want to modify is
/usr/lib/tztab. Unlike other flavors of UNIX, HP-UX is unuque in that the time changes are managed by this textfile. You can do the changes yourself OR you can install the newly released patch, PHCO_34342, that will make the changes for you. The Perl install is very straightforward and should really be a part of any UNIX box these days. You can swinstall it from any of the Application CD sets or from: http://hpux.cs.utah.edu/hppd/hpux/Languages/perl-5.8.7/

One of the best features of Perl is that it is much more platform independent that most scripting languages. In fact, if you install one of the free Perls (e.g. www.activestate.com) on your Windowes box that same Perl script will tell you about your PC timechanges as well -- without modification. However, Windows is going to take more than a text editor to make it recognize the new time changes.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: Day light saving time

Hi Maria:

You should have Perl installed already as a part of a standard 11i release. You can verify with:

# swlist | grep -i perl

# whereis perl

You will probably find a Perl version installed in '/opt/perl'. Ideally, You should have some version of 5.8 as shown when you do:

# perl -v

You may find a very old version of Perl in '/usr/contrib/bin'. Ignore this one.

If you need a current version of Perl installed, you can download a set of binaries for HP-UX and install them with the standard 'swinstall' from here:

http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=PERL

In HP-UX, the rules for timezones are found in '/usr/lib/tztab'. Have a look at the manpages for 'tztab(4)' for the manner in which the table should be interpreted.

http://www.docs.hp.com/en/B2355-60127/tztab.4.html

Look too, at the 'cron(1M)' manpages for information on how 'cron' interprets the TZ environmental variable:

http://www.docs.hp.com/en/B2355-60127/cron.1M.html

Variables, as for instance 'TZ' can be set for the duration of a commandline only by declaring the variable and its value followed by whitespace (blanks, tabs) and the command:

# TZ=EST5EDT date
# TZ=GMT date

Very recently, patches for the standard 'tztab' have been released with daylight saving changes for the United States and Australia.

For 11.0, use: PHCO_34266

For 11.11 use: PHCO_34342

For 11.23 use: PHCO_34375

Should you have any systems running 10.20, you can simply replace its '/usr/lib/tztab' with one of the above, since there are no official patches released for that out-of-support release.

Regards!

...JRF...



Peter Gillis
Super Advisor

Re: Day light saving time

Bill / clay Thanks for all info. I will give it a go this afternoon. Let you know how I go...(so there will probably be more questions....but hell, wont fall asleep!) thanks
Maria
James R. Ferguson
Acclaimed Contributor

Re: Day light saving time

Hi (again) Maria:

One more thing. Once the modification has been made to the '/usr/lib/tztab' any new process started will fall under the new "rules". A restart of 'cron' would cover cron tasks. New logins would execute 'login()' so the processes spawned by those would also abide by the new time changes. A reboot of the server sometime before the mandated time change would then align everything --- things that are running and things that are later scheduled to run.

Regards!

...JRF...
Peter Gillis
Super Advisor

Re: Day light saving time

Ok, Well I do already have perl installed -
# whereis perl
perl: /usr/contrib/bin/perl /opt/perl/bin/perl /opt/perl/man/man1/perl.1

# swlist | grep -i perl
perl B.5.6.1.F Perl Programming Language.



If I try to run Clay's script, this results:

charon> # ./dst.pl
interpreter "/usr/bin/perl" not found
sh: ./dst.pl: not found.
charon> # dst.pl
sh: dst.pl: not found.
charon> #
(I am in the directory where I have Clay's script)
On looking at the script I can see the 1st line is stating a perl shell. I know I dont have that on our system. So, does this look like perl has not been configured on our system? I know this is really basic, apologies.
Maria

A. Clay Stephenson
Acclaimed Contributor

Re: Day light saving time

The Perl script has a "shebang" that tells it to execute as /usr/bin/perl. Your will need to add a symbolic link such as:
ln -s /opt/perl5/bin/perl /usr/bin/perl ---
this is normally a good thing to do because /usr/bin should be in everyone's PATH.

whem you install my Perl script make sure that you do a "chmod 755 dst.pl" so that the execute bit is set. When you do these two things then the script will execute as simply "dst.pl".
If it ain't broke, I can fix that.
Patrick Wallek
Honored Contributor

Re: Day light saving time

You can do 1 of 2 things:

1) Link /opt/perl/bin/perl to /usr/bin/perl

# ln -s /opt/perl/bin/perl /usr/bin/perl

2) Replace the #!/usr/bin/perl line in Clay's script with #!/opt/perl/bin/perl

Either should allow you to run the script.

Peter Gillis
Super Advisor

Re: Day light saving time

Clay/ patrick ... thanks heaps.
I have been able to run the dst.pl script, although I did have to put the ./ in front.
The output from the job was as follows:

charon> # ./dst.pl
Sun Mar 26 02:59:59 EDT 2006 --> Sun Mar 26 02:00:00 EST 2006
Sun Oct 29 01:59:59 EST 2006 --> Sun Oct 29 03:00:00 EDT 2006

Looks as though this system set to change time at 2:59am back to 2:00am on Mar 26th. Reading it right?? (amazing!)

I am thinking now that I would load up patch PHCO_34342 and then rerun this script, hopefully this would then have the correct date.

Thank you so much every one. You are some of the best!!

Maria
A. Clay Stephenson
Acclaimed Contributor

Re: Day light saving time

Yes, install the patch and then rerun the script. The only other "gotcha" is that if you are not going to reboot before the time transition, you should stop and restart the cron daemon to force it to reload tztab.
If it ain't broke, I can fix that.
Peter Gillis
Super Advisor

Re: Day light saving time

Thanks Clay. Perl script works a charm and the patch loaded no problems - now we are set for the 2nd of April.!
Maria
Peter Gillis
Super Advisor

Re: Day light saving time

Everyone....thanks heaps. The DST.pl script, and the DST patch PHCO_34342 have all done the trick.
Maria