Showing results for 
Search instead for 
Did you mean: 

change time on hpux

Go to solution
Peter Ko_2
Frequent Advisor

change time on hpux

# date
Thu May 26 18:23:23 CDT 2011

above is my hpux 11.23 time. I wanted to change 21:23 (it is three hour off). when i
use the following command...
# date -u 052521212011
date: do you really want to run time backwards?

it give me UTC time...

when i ran set_parms timezone, change it back to CST... the time become incorrect again.

Please help.
Steven Schweda
Honored Contributor

Re: change time on hpux

> # date -u 052521212011

> it give me UTC time...

man date

If you don't want to see (or specify) UTC,
then why say "-u"?

> when i ran [...]

As usual, showing actual commands with their
actual output can be more helpful than vague
descriptions or interpretations. For

> [...] hpux 11.23 [...]

uname -a
Honored Contributor

Re: change time on hpux

# date -u 052521212011

This command would set the time to May 25, 21:21 UTC... or 16:21 CDT. That would change the clock backwards from the current setting.

The -u option means "UTC", not "update".

> it give me UTC time...

No, you gave the system a new time value and explicitly told that it's the current UTC time. The new local time was calculated from that value, based on the current timezone setting.

Please run "echo $TZ": it will display your current timezone setting in full.

If you have a convenient source of UTC time, for example a NTP time server, use it to set the system clock to the correct UTC time (use "ntpdate " or "date -u " to set it).

Then change the timezone setting until the local time is correct for you. When you change the timezone setting, the system's idea of the local time will adjust automatically: the system's idea of the UTC time will stay in sync with the real UTC time.

If it's more convenient for you to set the time using local time, *first* find the correct timezone setting for you, *then* set the time using "date ".

In HP-UX 11.23, this is controlled by the TZ environment variable. Its system default value is set in /etc/TIMEZONE. You can experiment by changing the TZ setting in your shell session: that way, it will only take effect for the commands you run in that session. Once you find the setting that works for you, you can use "set_parms timezone" or edit /etc/TIMEZONE manually.

After making changes to /etc/TIMEZONE, you should reboot to make sure all the system daemons will be using the new setting.

CDT = Central Daylight Time. If you want CST (Central Standard Time) year-round, your TZ value should be "CST6", nothing else. It contains the timezone name and the UTC offset value: that's all the system needs.

If the TZ value includes a DST timezone name (e.g. "CST6CDT"), then the system will also look into /usr/lib/tztab to find the DST transition rules, and the system will automatically shift between DST and standard time. In this case, you should make sure your /usr/lib/tztab is up to date, as USA's DST rules have recently been changed.

The latest HP-provided tztab patch for 11.23 seems to be PHCO_39173.

You might find that the sign of the UTC offset number in the TZ variable is the opposite of what you'd expect. That's as it should be: blame the POSIX standards. It's defined as "the value you must add to the local time to get UTC time".

Peter Ko_2
Frequent Advisor

Re: change time on hpux