Operating System - HP-UX
1826772 Members
2438 Online
109702 Solutions
New Discussion

Re: How to set the time ?

 
Franky Leeuwerck
Frequent Advisor

How to set the time ?

Hello there,
I am working on a HP-UX 11 server. I'd like to do some tests with time data ( daylight saving time zone versus standard time zone ). I noticed you can change the system time in SAM. I can hardly believe it is that easy. Am I overlooking certain aspects ?

Thanks,

Franky Leeuwerck
9 REPLIES 9
Stefan Farrelly
Honored Contributor

Re: How to set the time ?


Its even easier than that;

/sbin/set_parms date_time

It will then prompt you for new date+time
Im from Palmerston North, New Zealand, but somehow ended up in London...
Edward Alfert_2
Respected Contributor

Re: How to set the time ?

changing the system time can cause problems... make sure you know if you have any scheduled activity.

for instance... cron jobs depend on the time... if you change the time to an earlier time, then a cron job might run again... if you change the time forward, then a cron job may never run...

I hope you aren't testing with a production system.
"Do what you love and you will never work a day in your life." - Confucius
A. Clay Stephenson
Acclaimed Contributor

Re: How to set the time ?

Actually the better and safer way is to leave the time as it is and manipulate your TZ variable. That way only your environment is affected. One has to be very careful especially when setting system time backwards as many file datestamps can be confused especially on development machines where the make utility is used. man 5 environ for details on setting the TZ variable.
If it ain't broke, I can fix that.
Magdi KAMAL
Respected Contributor

Re: How to set the time ?

Hi Franky,

The command is as follow :

#date mmddhhMM[[cc]yy]

mm : two positions for month
dd : two positions for day
hh : two positions for hours
MM : two positions for minutes
cc : two positions for century ( optional )
yy : two positions for years ( optional )

If you set time forward is without problems.
If you set time backword, you will be propted to confirm [Yes / No ].

Notice:
It's dangerous to play with the system time, since it's used in all process computations spacially in scheduling !

Magdi
James R. Ferguson
Acclaimed Contributor

Re: How to set the time ?

Hi Franky:

You can set the time of your server backwards or forwards with the 'date' command (see the man pages), BUT as already noted their are ramifications for logging and for cron tasks.

You might consider setting the timezone (TZ) variable for your testing. For example, I am in Eastern Standard Time and my TZ=EST5EDT. If, in a script, for example, I want to pretend that it is Pacific coast time, I can do this:

# TZ=PST8PDT date

There is no delimiter other than a blank between the PST8PDT and 'date'. In this fashion, the date and time returned will be Pacific time for only the duration of the command.

Regards!

...JRF...
Franky Leeuwerck
Frequent Advisor

Re: How to set the time ?

Everyone thanks for the quick replies.

I tried the tip from Stefan.
The system responded with :
The date and time have been set to: Wed Aug 29 17:54:00 METDST 2001

I assume METDST indicates Middle European Time with Daylight Saving Time. As a test, I put the time on 29 december 2001 18:00:00 and noticed Unix automatically switched to standard time instead of daylight saving time.
Sat Dec 29 18:11:00 MET 200

Which timezones can I set and how can I do it ?
Franky Leeuwerck
Frequent Advisor

Re: How to set the time ?

Again everyone thanks a lot. All answers together can solve my problem.

Regards,
Franky
James R. Ferguson
Acclaimed Contributor

Re: How to set the time ?

Hi Franky:

For more information, see 'man 4 tztab'. If you list ('cat' or 'more') /usr/lib/tztab you will see the defined timezones and their transition points.

As indicated, you can set the TZ variable within a script to whatever you desire. System-wide, /etc/TIMEZONE is used to hold the default. This file is sought and sourced in /etc/profile when a login occurs.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: How to set the time ?

Unix is unique in that all time is kept in GMT or Zulu (or most accurately stated, Universal Coordinated Time). The time of day never changes for Daylight Savings Time. Instead, all of the time related system calls and comands (like date and ll) will have the system time translated through the tztab table usinf $TZ as the index.

This means that anyone in any location can set TZ to match their local timezone and the machine will magically show all time values in local time. Daylght Savings time is simply a formatting task...tztab defines the rules and the time is formatted for the local rules. You can even create your own private timezone. (why heck, if politicians can do it, sysadmins should be able to do it too).


Bill Hassell, sysadmin