1834161 Members
2302 Online
110064 Solutions
New Discussion

changing time

 
SOLVED
Go to solution
tarek_3
Frequent Advisor

changing time

Hi
I should modify the system clock on my unix 10.20 machine, and adjust it according to Lebanon's summer time clock by adding one hour at midnight.
can i modify the time automatically without using a "at" command or script?
is there any file where i should modify or configure?thanks for your help.

14 REPLIES 14
Patrick Wallek
Honored Contributor

Re: changing time

If your TZ variable is correct for your Timezone then you should not have to do a manual date adjustment on your system. It will be automatic.
Pete Randall
Outstanding Contributor
Solution

Re: changing time

I'm sure every one will advise you that you should set up NTP, but if you just want to keep it simple, make a script that you can use with at:

echo "yes" > /tmp/yes_time
CTIME=`0328100803`
date $CTIME < /tmp/yes_time


Change the CTIME value to what you want it to be when the at job runs.


Pete

Pete
A. Clay Stephenson
Acclaimed Contributor

Re: changing time

If /etc/TIMEZONE is set correctly, you need to do absolutely nothing. Man tztab to determine the correct setting. Also, note that TZ only affects how the time is displayed, UNIX simply counts seconds since Jan 1, 1970. Also note that differnt user might have very different TZ settings and that works as well. Processes like cron are dependent upon the TZ setting (almost always taken from /etc/TIMEZONE) when the cron daemon was started. Man crontab for details on how summer/daylight saving time is handled by cron.

Again, I strongly suspect that you have to do absolutely nothing.
If it ain't broke, I can fix that.
Michael Duthie
Trusted Contributor

Re: changing time

Why don't you have the correct timezone set?

Use # set_parms timezone

and follow your nose.
Steven E. Protter
Exalted Contributor

Re: changing time

If for some reason you ned to do it manaully or at a time other than when HP thinks its neesd to happen, you can use the date command.

man date

The prior posts however are the better way to go.

I also recommend if you have access to the Internet or an internal time server you set up ntp to maintain system time.

Here is a great thread on the subject.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xf136b941255cd71190080090279cd0f9,00.html

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
tarek_3
Frequent Advisor

Re: changing time

thanks all
but i 'am not very good with timing.how can i know that the seting of TZ is correct.
Donald Kok
Respected Contributor

Re: changing time

check for /usr/lib/tztab and his manpage. The TZ you have in use must be in there. You can check in it if your Daylight Savings time will be OK.

Is your TZ correct? If the outcome of date -u is right? Then your TZ is OK.

HTH
Donald
My systems are 100% Murphy Compliant. Guaranteed!!!
Michael Duthie
Trusted Contributor

Re: changing time

Try using set_parms timezone

Select Africa, then unlisted then GMT+2.


Mike
Karl Balsmeier
Advisor

Re: changing time

You can also modify /etc/profile

# Set the TIMEZONE

if [ -r /etc/TIMEZONE ]
then
. /etc/TIMEZONE
else
TZ=PST8PDT # change this for local time.
export TZ
fi

And also make sure /etc/TIMEZONE has the 7 character value for lebanon.

set_parms timezone works well also , buit I like tha manual settings as well, especially, I paste the variable above into each user's /home/user/.profile, that way there's simply no issue with time anymore, especially gleaning advice from previous postings...

good luck!


"Unix is the Net"
tarek_3
Frequent Advisor

Re: changing time

hi thanks again
is there any way to know that the when the system will change the time?
Donny Jekels
Respected Contributor

Re: changing time

if you have *.info enabled in your /etc/syslog.conf the information will be updated in your syslog.

you could run script to tail -f /var/adm/syslog/syslog.log
and grep for time and then let it email you.

that would be my solution without spending a dime.
no I am not saying there is not a tool out there that does just what you're looking for.
"Vision, is the art of seeing the invisible"
Frank Slootweg
Honored Contributor

Re: changing time

> is there any way to know that the when the system will change the time?

The system will *not* "change" the time, because the *system* is running in UTC (Universal Time ...) also known as GMT (Greenwich Mean Time).

What *will* change is how the system *presents* *local* time, i.e. the result of the "date" command and the localtime() and similar functions (see the ctime(3C) manual page).

Please post the content of the file /etc/TIMEZONE and give an example output from the "date" command and indicate whether the local time is correct or not.

Example:

I live in The Netherlands, also known as "Holland". We now have "summertime" (Daylight Saving Time, DST). My info is:

$ cat /etc/TIMEZONE
TZ=MET-1METDST
export TZ
$ date ; date -u
Mon Mar 31 13:41:35 METDST 2003
Mon Mar 31 11:41:35 UTC 2003
$

I.e. we are in the MET, Middle European Time, timezone. If you lookup the MET-1METDST entry in the /usr/lib/tztab file, you will see that our summertime/DST is indeed 2 hours later than UTC/GMT (and our wintertime/non-DST) is 1 hour later than UTC/GMT.

I hope this answers your questions.
Adam J Markiewicz
Trusted Contributor

Re: changing time

Hi

I feel I should expose this.
As already stated above: Summer time (or Daylight Saving Time - DST) is only the way how the system *interprets* its internal timer (that measures number of seconds from 1.1.1970).Once this is set correctly it should be left *untouched*. Most internal time related activity is based on the value of this (file-related dates for example).
For DST the mechanism of TimeZones should be used.You can use any of already predefined, check if any suits you:
man tztab
more /usr/lib/tztab
check also the current settimg:
echo $TZ
which is defined at the startup in the script:
/etc/TIMEZONE
(where could be adjusted if needed to make permanent).

If you won't find anything that suits you, I think you could create TimeZone for yourself. The idea, although a little bit complicated, is very well explained in man tztab.

Good luck
Adam
I do everything perfectly, except from my mistakes
Karl Balsmeier
Advisor

Re: changing time

Tarek,

It will show up once someone logs out and then back in and run the date command to confirm your changes took effect. No need to reboot.

-karlski
"Unix is the Net"