System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

time changes, when configured as ntp client

 
SOLVED
Go to solution
Maaz
Valued Contributor

time changes, when configured as ntp client

OS: SLES 10 SP 1/ 2
OS: SLES 9 SP 3/4


I configure the system time manually, as
# yast2 timezone

then in Region, select "Etc"
then in Time Zone, select "GMT +6"
then Hardware Clock set To UTC
then configure the time 17:07

# date
Tue Jun 3 17:07:57 GMT+6 2008

OK,

after manually configuring, I ran the following command

# rcntp stop

# ntpdate clock.nc.fukuoka-u.ac.jp
3 Jun 06:08:36 ntpdate[6693]: step time server 133.100.9.2 offset -39596.070956 sec
# ntpdate clock.nc.fukuoka-u.ac.jp
3 Jun 06:08:43 ntpdate[6694]: adjust time server 133.100.9.2 offset 0.006033 se c
# ntpdate clock.nc.fukuoka-u.ac.jp
3 Jun 06:08:48 ntpdate[6695]: adjust time server 133.100.9.2 offset 0.009886 se c
# ntpdate clock.nc.fukuoka-u.ac.jp
3 Jun 06:08:55 ntpdate[6696]: adjust time server 133.100.9.2 offset -0.008568 s ec

now problem is that after configuring the time via ntp server(clock.nc.fukuoka-u.ac.jp or any other ntp server, in Asia) the time of my machine(sles10 sp 1/2, sles 9 sp 3/4) goes almost 11 hours BACK, i.e

# date
Tue Jun 3 06:08:57 GMT+6 2008

why the time is 06:08 instead of 17:08 ? why system time goes 11 hours back ? please help

Regards
Maaz
11 REPLIES
Ivan Ferreira
Honored Contributor

Re: time changes, when configured as ntp client

>> then Hardware Clock set To UTC
¿Are you sure that your hardware clock is using UTC time?

>> then configure the time 17:07

You don't have to configure the time, you just need to run ntpdate. If the time adjusted by ntpdate does not match the time you need, your timezone is not correct.

Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Matti_Kurkela
Honored Contributor

Re: time changes, when configured as ntp client

Note that "GMT+6" specifies a timezone 6 hours _west_ of Greenwich. All timezones on the eastern hemisphere should have a minus sign in the timezone identifier. You can blame the committee that designed the timezone identifiers... :-/

The ntpdate command works using UTC time, and that's what all Unix and Linux timekeeping internally uses. So the ntpdate command sets your system clock to correct UTC time (you can verify this by using the "date -u" command) but the mapping from UTC to local time is wrong.

Until now, the wrong mapping has hidden a big error in the UTC time value.

MK
MK
Maaz
Valued Contributor

Re: time changes, when configured as ntp client

Hi Ivan Ferreira
>Are you sure that your hardware clock is using UTC time?
I dont know ;( ... but atleast I enable/select the "Hardware Clock set To UTC" option.

>If the time adjusted by ntpdate does not match the time you need, your timezone is not correct.
ASIA/PAKISTAN/Karachi is +5 GMT(SEP-MAY), and now a days (daylight saving) its +6 GMT till August. The change puts Pakistan six hours ahead of the GMT.


Maaz
Valued Contributor

Re: time changes, when configured as ntp client

Hi Matti Kurkela
>Note that "GMT+6" specifies a timezone 6 hours _west_ of Greenwich. All >timezones on the eastern hemisphere should have a minus sign in the >timezone identifier.

YES, you are righrt, I just manually configure the system time WED 4 JUNE 12:55 PM -6 GMT, and then

# ntpdate clock.nc.fukuoka-u.ac.jp
4 Jun 12:57:42 ntpdate[4388]: adjust time server 133.100.9.2 offset 0.003521 sec
# date
Wed Jun 4 12:57:43 GMT-6 2008
# hwclock
Wed Jun 4 12:57:45 2008 -0.000486 seconds

Mutti Kurkela can you please share the reference(url/doc etc) for your following statement:
>All timezones on the eastern hemisphere should have a minus sign in the >timezone identifier

and what should I do now ? I mean should I configure my system timezone as -6 GMT ?

Regards
Maaz
Maaz
Valued Contributor

Re: time changes, when configured as ntp client

Matti Kurkela
>Until now, the wrong mapping has hidden a big error in the UTC time value.

I think I must report this BUG to novell ... should I ?
Ivan Ferreira
Honored Contributor

Re: time changes, when configured as ntp client

It's not a bug.

>> I dont know ;( ... but atleast I enable/select the "Hardware Clock set To UTC" option.

The question is asking you if you have UTC time in your bios instead of local time. If so, select yes.

And probably yes, you should use -6. Sometimes, as said above, the time zone "name" or location does not match the time offset.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Maaz
Valued Contributor

Re: time changes, when configured as ntp client

Hi Ivan thanks for your continuous and kind support/help.

>...if you have UTC time in your bios instead of local time.

ooopps again a strange issue ...
Ivan I found that when I check the system BIOS, BIOS always shows the time almost 6 hours ahead.

i.e when system shows
# date && hwclock --show
Wed Jun 4 16:20:46 GMT-6 2008
Wed Jun 4 16:20:46 2008 -0.000461 seconds

then init 6
The BIOS shows the time Wed Jun 04 22 23 03

now again just after login
# date && hwclock --show
Wed Jun 4 16:27:20 GMT-6 2008
Wed Jun 4 16:27:21 2008 -0.000450 seconds

you can see the BIOS time is almost 6 hours in advance/ahead.
but the hwclock and date shows the same time

>the time zone "name" or location does not match the time offset.
is there any workaround ? how can i fix it ? for our environment this is very important.



Matti_Kurkela
Honored Contributor
Solution

Re: time changes, when configured as ntp client

Your original time error still remains in the BIOS clock. Furthermore, your system's startup scripts assume that the BIOS clock is running in local time for some reason.

After running ntpdate, you should run "hwclock --systohc --utc" to update the BIOS clock to the correct UTC value. The "--utc" option is important here. The /etc/adjtime file tells the system whether the BIOS clock is supposed to be in local time or UTC time: if this file is wrong, the "--utc" option corrects it automatically.

Unfortunately, some distributions store the information "BIOS clock is running in local/UTC time" in some other location too; you should make sure that both /etc/adjtime and that other location are in agreement, otherwise strange things may happen.

In Linux, the system clock (visible using "date" or "date -u") is created by the OS. It's completely separate from the hardware-based BIOS clock that keeps time when the system is shut down.

Very early in the Linux boot process, the system clock gets its time from tha BIOS clock. If you run ntpd, it will automatically synchronize the BIOS clock to the (NTP-corrected) system clock. If you just use ntpdate, you must synchronize the BIOS clock manually (using the hwclock command) whenever you change the system time.

If your timezone is 6 hours ahead of the GMT time, you should specify it in all Unix systems as GMT-6, not as GMT+6.

You can check the timezone conversion rules using the "zdump" command. It prints time values in UTC and the matching times in the local time of the timezone you specify.
For example:

# zdump -v Etc/GMT+6
Etc/GMT+6 Fri Dec 13 20:45:52 1901 UTC = Fri Dec 13 14:45:52 1901 GMT+6 isdst=0 gmtoff=-21600
Etc/GMT+6 Sat Dec 14 20:45:52 1901 UTC = Sat Dec 14 14:45:52 1901 GMT+6 isdst=0 gmtoff=-21600
Etc/GMT+6 Mon Jan 18 03:14:07 2038 UTC = Sun Jan 17 21:14:07 2038 GMT+6 isdst=0 gmtoff=-21600
Etc/GMT+6 Tue Jan 19 03:14:07 2038 UTC = Mon Jan 18 21:14:07 2038 GMT+6 isdst=0 gmtoff=-21600

As there are no DST rules in the generic "GMT+6" specification, the command displays the times from the beginning of the known DST data (December 13 1901) to the end of the traditional Unix time_t epoch (Jan 19 2038).

As you can see, "GMT+6" means that the time is 6 hours _behind_ of UTC/GMT, not 6 hours _ahead_.

If you're located in a timezone 6 hours _east_ of Greenwich, you should configure your timezone settings to "GMT-6". This is just how the POSIX timezone designation works: the signed number is what you must add to your local time to get the GMT time, not vice versa.

Reference:
http://www.twinsun.com/tz/tz-link.htm
(see the end of the paragraph "Time Notation")

MK
MK
Maaz
Valued Contributor

Re: time changes, when configured as ntp client

Hi Matti Kurkela, millions of thanks for such a detailed and descriptive response/help/support.

>After running ntpdate, you should run "hwclock --systohc --utc" to update the >BIOS clock to the correct UTC value.

I ran the ntpdate, then "hwclock --systohc --utc", but still BIOS shows the wrong time.

date and hwclock always shows the same time.
# date && hwclock
Thu Jun 5 13:12:39 GMT-6 2008
Thu Jun 5 13:12:39 2008 -0.000485 seconds
---

# cat /etc/adjtime
0.000000 1212649604 0.000000
1212649604
UTC

>If your timezone is 6 hours ahead of the GMT time, you should specify it in all >Unix systems as GMT-6, not as GMT+6
I think these Unix peoples don't have Bosses[ atleast My boss doesn't agree on -6 GMT :( ].

>If you're located in a timezone 6 hours _east_ of Greenwich, you should >configure your timezone settings to "GMT-6"
OK, it means if i am located 6 hours behind of GMT, then only I can use GMT+6.

here is output of
# zdump -v GMT-6
GMT-6 Fri Dec 13 20:45:52 1901 UTC = Sat Dec 14 02:45:52 1901 GMT isdst=0 gmtoff=21600
GMT-6 Sat Dec 14 20:45:52 1901 UTC = Sun Dec 15 02:45:52 1901 GMT isdst=0 gmtoff=21600
GMT-6 Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 09:14:07 2038 GMT isdst=0 gmtoff=21600
GMT-6 Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 09:14:07 2038 GMT isdst=0 gmtoff=21600


Regards
Maaz
Matti_Kurkela
Honored Contributor

Re: time changes, when configured as ntp client

Sorry. The hwclock command seems to always display the BIOS clock time as translated to your local timezone.

The hwclock man page says:
--show Read the Hardware Clock and print the time on Standard Output. The time shown is always in local time, even if you keep your Hardware Clock in Coordinated Universal Time.

You should be able to verify this by this procedure:
1.) make sure your timezone is correctly set
2.) synchronize your system clock with ntpdate (verify with "date" and "date -u")
3.) run "hwclock --systohc --utc"
4.) reboot the machine and view the clock in the BIOS menu; you should see it's running in UTC time.

As to why the Unix timezone setting of "GMT-6" means "local time is GMT _plus_ 6 hours", that's what the POSIX.1 standard says. Blame the committee that defined the standard, if you wish... But remember that the sign of the number in the timezone designation is the opposite of what you would expect.

MK
MK
Maaz
Valued Contributor

Re: time changes, when configured as ntp client

Hi Matti Kurkela,

# ntpdate clock.nc.fukuoka-u.ac.jp

# date && date -u && hwclock
Fri Jun 6 10:48:45 GMT-6 2008
Fri Jun 6 04:48:45 UTC 2008
Fri Jun 6 10:48:45 2008 -0.000421 seconds

then I ran,
# hwclock --systohc --utc

reboot the system to check the BIOS time, it is still 6 hours different. the BIOS clock is showing the same time as the output of "date -u" command.

but always the hwclock and date command reports the same and right time.

This is not a big issue.

Anyhow thanks once again.
Regards
Maaz