1834391 Members
1643 Online
110066 Solutions
New Discussion

Re: TimeZone

 
malay boy
Trusted Contributor

TimeZone

Guru's,
Need some advice on timezone.I always no good at the time.

I have a server which use timezone JST-9.

when I login to my server using my id and issue date , I have as below :

jpamin:/home/malayboy >date
Fri Jul 11 09:31:08 JST 2003

jpamin:/home/malayboy >env|grep TZ
TZ=JST-9

But when I logon to root here what I got :

# date
Thu Jul 10 20:33:11 EDT 2003

# env|grep TZ
#
(which TZ are not set).

# export TZ=JST-9
# env|grep TZ
#
(which are still nothing)...

SENARIOS:
I create a ftp job between two servers running at 2:00am from jpamin to jphafiz using root account.

jphafiz timezone TZ=JSP-9.

Problem : now the job are "hanky panky"..goes crazy..

any document or help or some heavenly light are appreciate...

regards
mB


There are three person in my team-Me ,myself and I.
14 REPLIES 14
malay boy
Trusted Contributor

Re: TimeZone

Here are jpamin /etc/TIMEZONE setting :

# more /etc/TIMEZONE
TZ=JST-9
export TZ
TIMEZONE: END
There are three person in my team-Me ,myself and I.
Rajeev  Shukla
Honored Contributor

Re: TimeZone

See the TIMEZONE vaiable is set in /etc/profile


so when you login and the /etc/TIMEZONE file exists it executes that and sets what ever is in that file, but for some reasons it seems by loging as other users it is working but not with root.
And i know the problem lies in exporting the variables by root. Can you try to export something else say..
#export HELLO=23
and display
#echo $HELLO
i think there is the problem as root even this wouldn't be working...can you pls check and also check the permissons of /etc, /etc/profile and /etc/TIMEZONE file.

Thanks
Rajeev
Con O'Kelly
Honored Contributor

Re: TimeZone

Hi mB

That's an interesting problem!!
I assume from what you said the main issue is the problem setting the correct timezone for root??

I'd look through the /etc/profile, root's .profile and your own .profile to see if there's any references to TZ.

As you're probably aware TZ is set at login by /etc/profile sourcing the TZ variable in /etc/TIMEZONE. This can then be overridden by users setting their own TZ variable in their .profile.

Cheers
Con
malay boy
Trusted Contributor

Re: TimeZone

Hi Guy's,
I manually put below :

export TZ=JST-9

in the jpadmin root .profile but still date command give me EDT as the time zone.

# date
Thu Jul 10 21:32:56 EDT 2003

Here are the permission on the file :

# ll profile
-r--r--r-- 1 root bin 2689 Aug 9 2001 profile
# pwd
/etc
# ll TIMEZONE
-r--r--r-- 1 bin bin 19 Apr 9 2001 TIMEZONE

# ll|grep etc
dr-xr-xr-x 28 root bin 6144 Jul 8 04:12 etc

any document which I could look.

regards
mB

There are three person in my team-Me ,myself and I.
Rajeev  Shukla
Honored Contributor

Re: TimeZone

Does exporting of anyother vaiables work for root from system prompt say...

#export HELLO=23
and display
#echo $HELLO

Rajeev
malay boy
Trusted Contributor

Re: TimeZone

Rajeev,
Really appreciate your response.But here are the testing .

# export OK=mB
# echo $OK
mB
#

regards
mB
There are three person in my team-Me ,myself and I.
Con O'Kelly
Honored Contributor

Re: TimeZone

Have to admit mB I'm not sure of the problem.
You could also look at /usr/lib/tztab file.
Is JST defined in here?
Can you set the TZ for root using another timezone defined in tztab??

Cheers
Con
Rajeev  Shukla
Honored Contributor

Re: TimeZone

Thats very strange..then atleast this
# export TZ=JST-9
# echo $TZ

should work...i wonder why its playing..

Or one more option you might give a try is set the time zone again again using
/sbin/set_parms timezone
and reboot the machine and see how is goes..

Cheers
Rajeev
malay boy
Trusted Contributor

Re: TimeZone

Rajeez,

Yap below work:
#export TZ=JST-9
# echo $TZ
JSP-9

but env|grep TZ

nothing showed...

my brain are melting now ...

regards
mB
There are three person in my team-Me ,myself and I.
Bill Hassell
Honored Contributor

Re: TimeZone

Are you using Xwindows (as in CDE)? You may not be running ANY profiles at all. Are you using /sbin/sh for root? If not, change it back to /sbin/sh (which is NOT a Bourne shell). How do you login as an ordinary user versus root? Is it through a telnet connection or rlogin or remsh or ssh? Or do you login by borrowing a terminal emulator from the server (such as dtterm, xterm or hpterm)?

The question is whether /etc/profile and then .profile are actually run during login. Start with some echo statements in /etc/profile and .profile to see if root actually does a login.

As far as the ftp job at 2am, I suspect that this is a cron job...VERY IMPORTANT: cron never performs a login so the environment for a cron job is very small. From the man page for crontab

"cron supplies a default environment for every shell, defining:

HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry."

In other words, TZ must be set (along with any other parameters you need) inside your script or program.


Bill Hassell, sysadmin
Steven E. Protter
Exalted Contributor

Re: TimeZone

Small security gotcha.

You should NOT allow ftp on either box to the root user.

Its a major security hazard, especially if there is a remote or public connection between the machines.

Most scripted ftp scenarios have the root password hard coded in the script. Also very bad.

Install secure shell on both machines and follow Chris Vail's guide to exchanging public keys. Then you can use the scp command to transfer files.

Secure shell
http://www.software.hp.com/cgi-bin/swdepot_parser.cgi/cgi/displayProductInfo.pl?productNumber=T1471AA




This of course does not earn points or solve your problem. As to that, here are some interesting docs.

http://docs.hp.com/cgi-bin/otsearch/getfile?id=/hpux/onlinedocs/939/KCParms/KCparam.TimeZone.html&searchterms=Timezone%7cTZ&queryid=20030710-210606

http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/TKP-90202/TKP-90202_top.html&con=/hpux/onlinedocs/TKP-90202/00/01/166-con.html&toc=/hpux/onlinedocs/TKP-90202/00/01/166-toc.html&searchterms=Timezone%7cTZ&queryid=20030710-210606

Still, what about clock drift. That can still drive you up a proverbial wall. Well, Dr. David Mills invented a solution. ntp

Here is some HP doc on that plus links to Dr. Mills' work.

Configuration
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B2355-90685/B2355-90685_top.html&con=/hpux/onlinedocs/B2355-90685/00/00/63-con.html&toc=/hpux/onlinedocs/B2355-90685/00/00/63-toc.html&searchterms=configuration%7cntp&queryid=20030710-210811

Advanced topics
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B2355-90685/B2355-90685_top.html&con=/hpux/onlinedocs/B2355-90685/00/00/65-con.html&toc=/hpux/onlinedocs/B2355-90685/00/00/65-toc.html&searchterms=configuration%7cntp&queryid=20030710-210811

Troubleshooting
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B2355-90685/B2355-90685_top.html&con=/hpux/onlinedocs/B2355-90685/00/00/65-con.html&toc=/hpux/onlinedocs/B2355-90685/00/00/65-toc.html&searchterms=configuration%7cntp&queryid=20030710-210811

Dr. Mills stuff
http://www.ntp.org/documentation.html

Time Servers
http://www.tymserve.com/success_tva.html

Here is a think outside the box answer. Set both servers to Greenwich Mean Time, do ntp and
pick close time servers.

Now this post is a mouthful isn't it.

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
malay boy
Trusted Contributor

Re: TimeZone

Hi master bill,
Thanks for the response.Appreciate everybody response although every are busy I'm sure.

To answer to your question :

Q) Are you using Xwindows (as in CDE)?
A) No , I'm running Reflection and telnet to the box.No CDE

Q) Are you using /sbin/sh for root?
No.
A) # echo $SHELL

Q) How do you login as an ordinary user versus root? Is it through a telnet connection or rlogin or remsh or ssh? Or do you login by borrowing a terminal emulator from the server (such as dtterm, xterm or hpterm)?
A) All the same using telnet via reflection.

There are new finding :

if I logon as root, from su:

if I do :

# export TZ=JSP-9
# date
Thu Jul 10 22:59:17 EDT 2003
# echo $SHELL
/usr/bin/ksh

I still got that.

But if I changed the
to sh.

The above are correct.

regards
mB
There are three person in my team-Me ,myself and I.
Fragon
Trusted Contributor

Re: TimeZone

Hi mB,

From your description, it's a problem caused by your shell. Please check what shell your are use:
#ps|grep $$|awk '{print $4}'
sh
#badcommand
/sbin/sh: badcommand : not found

For root, the default shell must be /sbin/sh, that's exist in /etc/passwd, last field!

-ux
Bill Hassell
Honored Contributor

Re: TimeZone

The first problem is your use of su. NEVER run su without using the - option! Without using the - option, you are NOT really logging in, you are changing user ID's but /etc/profile and .profile will not be run and you will NOT change shells to the one specified for root.

To find out your current shell, just type:

echo $0

The fact that echo $SHELL does not produce anything indicates an abnormal login procedure. To see the shell that a current user is supposed to use:

grep ^$(whoami): /etc/passwd | cut -f7 -d:

Using su without the - is a bad security risk since su'ing to root can allow a hacker to compromise root's environment.


Bill Hassell, sysadmin