Operating System - HP-UX
1832757 Members
3077 Online
110045 Solutions
New Discussion

Re: Wrong time with su command

 
SOLVED
Go to solution
Viljami
Occasional Contributor

Wrong time with su command

This may be a easy one:

when switching user with su command the system time is wrong by 6 hours with the other user.

Checked different user´s profiles but found nothing wrong there, e.g. with time zone. The system is hp-ux 11.11

Thanks for any advice.

6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: Wrong time with su command

Hi:

Start as 'root' and echo the timezone variable:

# echo ${TZ}

Now do:

# su username # ...and echo ${TZ}
# su - username #...and echo ${TZ}

In the second case, the user's profile should run. Look in there for a different setting of TZ.

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: Wrong time with su command

I would have to assume that it has to be something in the profile. Try switching with and without the "-" option. Without it, the profile won't be executed and, I would think, the time should be the same.


Pete

Pete
Darrel Louis
Honored Contributor
Solution

Re: Wrong time with su command

Hi,

Please check your tz file in /etc/default.
Check if your Timezone in there is coorect.

Regards

Darrel
Bill Hassell
Honored Contributor

Re: Wrong time with su command

The time and date on HP-UX is always kept as GMT or UTC time. It is then translated to a particular timezone using the TZ variable. When you change user ID, a lot depends on whether you use the optional (but very important) - option (as in su - root). If you do not use -, then your new shell will have the privileges of the new user but the environment (including variables like TZ) will be unchanged, which is not good.

If you use the - option, then a login environment is created including running the new user's profile. Your date command under the new user will correspond to the current setting of TZ. Now this is the simple explanation. If you you are using Xwindows, the defaults in Xwindows will lead to unexpected results. Are you simply running a telnet connection and typing the su command or is it more complicated?


Bill Hassell, sysadmin
Kent Ostby
Honored Contributor

Re: Wrong time with su command

Please post for each user:

env | grep TZ
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Viljami
Occasional Contributor

Re: Wrong time with su command

Thanks for your answers!