LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-03-2008, 08:51 PM   #1
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Rep: Reputation: 15
ntp time is wrong


As far as I know I don't have any ntp time server installed.

Something is checking somewhere for the time. My system is set up for eastern standard time. Whatever is checking the time on the web is checking a server that is also on Eastern standard time and subtracting five hours.

To make matters even worse the other computer on my little home lan is checking the first computer and subtracting another five hours.

So my main internet connected computer is five hours early and the other computer is ten hours early.

I sort of enjoy the weird humor but this screws some software up.

Thanks for any help.
 
Old 03-04-2008, 04:16 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
That all sounds very strange. You didn't say how you have come to the conclusions you have. I will note that the NTP protocol uses UTC (essentially GMT), so if the machine running the server is set up properly, it shouldn't matter what time zone the server is in. (If your systems are using NTP.) Also, internally Linux systems run on UTC and just translate to a time zone when interacting with a user. Still, I can't help but observe that 5 hours is the offset between EST and UTC.

There are a couple of things I can think of that might get you some more info.
  • You can use a packet sniffer like wireshark or tcpdump to look at network traffic so you can see exactly what is going on
  • If you run netstat as root (or using sudo), the -p option will list the program and PID using each socket. If NTP is being used on the default port (udp/123), you probably want to use the -naup options.
 
Old 03-04-2008, 09:30 PM   #3
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Original Poster
Rep: Reputation: 15
more information now

I was guessing that the internet was involved.
Further checking lead to more information:

I have a dual-boot machine with windows 2000 on it. If I boot to windows and synch with an internet time server my time is correct. If I reboot to windows the time remains correct.
Now if I reboot to linux my time is again incorrect.
The following screenshots from windows show that something in the linux bootup is wrongly correcting UTC by five hours. I have no clue as to what is causing this or how to correct it.

At one point I had ntp daemon installed on this machine but I used Synaptic to completely remove it.

If I type sudo ntpdate pool.ntp.org the time is also correctly set. At the next boot it will be wrong again.

Actually I don't see a way to post images. What the picture shows is that UTC is incorrectly offset by 5 hours.

I'm not familiar with a way to check UTC in linux.
 
Old 03-04-2008, 10:18 PM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Your time at boot is wrong because your BIOS clock is not UTC but local time. UTC is Linux default, you have to tell Ubuntu your BIOS clock is set to local time. Windows does not support UTC time in BIOS.
 
Old 03-05-2008, 02:16 AM   #5
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
TMK, MS Windows requires the hardware clock to be local time. (Concurring with Emerson.) So you need to tell Linux to do the same. Ubuntu (at least in edgy) controls this in /etc/default/rcS. You want to change

UTC=yes

to

UTC=no

I suggest you make this change, then boot to MS and get the time synced up and then boot back to Linux and verify that everything is OK.

-------

Based on your last post, perhaps a quick review of the way time works in Linux is in order:

The hardware clock (aka BIOS clock, aka cmos clock) is normally ignored except at boot time and potentially at shutdown. While Linux is running, the kernel maintains the system time, which is in UTC. (Internally, it is the number of seconds since the beginning of 1970 UTC.) At boot time one of the init scripts (/etc/init.d/hwclock.sh in Ubuntu) reads the hardware clock and along with the setting described above and the locale info (if hwclock is not on UTC) sets the system clock. Unless you are running something like ntpd the kernel then pays no more attention to the hardware clock. (If you are running ntpd there is a mechanism to keep the hardware clock synced to system time.) By default, when Ubuntu shuts down, it will write the system time back to the hardware clock after again consulting the UTC and locale settings. (I don't know whether all distros now do this. It did not used to be standard.)

Normally programs that interact with the user will translate between system time (UTC) and local time. In particular GUI clocks (depending on their settings), the date command and the ls command will do this.

The default output of the date command is in local time (if the locale is properly set). If you use the -u option then date will display the time in UTC. There are actually a number of different things the date command can do depending on options. Check its man page for details.

In passing, I'll note that when you ran ntpdate it only set the system clock (not the hardware clock). However, unless you've changed the default behavior or unless things have changed since edgy, I would have expected the new time to get written to the hardware clock on shutdown.

I hope this brief explanation has been helpful.

Last edited by blackhole54; 03-05-2008 at 02:17 AM.
 
Old 03-05-2008, 07:24 AM   #6
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Original Poster
Rep: Reputation: 15
still baffled

Thanks for your response.

I had already read /usr/share/doc/util-linux/README.Debian.hwclock and checked /etc/edfault/rcS before I got the post.

rcS has UTC=no already set.

I set the clock correctly in BIOS this morning before boot. At some point dmesg shows the correct BIOS time. When the system arrives at the desktop it is again wrong by 5 hours.

Also if I'm understanding the system correctly the correct time found by ntpdate should set the BIOS clock at shutdown.

I'll shut down the system now and see if that is correct.
 
Old 03-05-2008, 07:51 AM   #7
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Original Poster
Rep: Reputation: 15
shutdown sets hardware clock correctly

After running ntpdate and obtaining a correct time I rebooted and checked the BIOS time. (hardware clock)

It reflected the time correctly. So shut down is setting the hardware clock.

I double checked my system time zone and it is also correct.

I am now totally baffled.
 
Old 03-05-2008, 09:58 AM   #8
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Are you saying the problem is fixed & you are concerned because you don't know why?
 
Old 03-06-2008, 01:12 AM   #9
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by wyndetygre View Post
After running ntpdate and obtaining a correct time I rebooted and checked the BIOS time. (hardware clock)

It reflected the time correctly.
Is the system time now correct or incorrect.? W/o options, does the date command show the EST time zone? How are you "checking BIOS time?" (E.g., what command do you run?)

Last edited by blackhole54; 03-06-2008 at 01:14 AM.
 
Old 03-06-2008, 08:39 AM   #10
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Original Poster
Rep: Reputation: 15
still incorrect

Sorry for the delay. A major storm blew out my internet connection.

My time is still working incorrectly.

Before ntpdate:
SOL:~$ date
Wed Mar 5 13:20:07 EST 2008
SOL:~$ date -u
Wed Mar 5 18:20:13 UTC 2008

SOL:~$ sudo ntpdate ntp.ubuntu.com
6 Mar 09:34:54 ntpdate[5650]: step time server 91.189.94.4 offset 71998.594685 sec

After ntpdate:

SOL:~$ date
Thu Mar 6 09:35:54 EST 2008
SOL:~$ date -u
Thu Mar 6 14:36:00 UTC 2008

If I now the now reboot and enter the bios management screen the bios clock will show Thu Mar 6 09:35:54 2008.

Afte I proceed to boot into the linux operating system the time will be wrong again.
 
Old 03-06-2008, 09:41 AM   #11
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Original Poster
Rep: Reputation: 15
after reboot

Just adding more information after a reboot.

Poenix cmos setup utility
Standard CMOS Features

Date Thu Mar 6 2008
Time 10:16:55

So the system is setting the hardware clock correctly at shutdown.

After exiting CMOS setup and linux boot.

SOL:~$ date
Thu Mar 6 05:18:48 EST 2008
SOL:~$ date -u
Thu Mar 6 10:18:57 UTC 2008
SOL:~$ sudo gedit /etc/default/rcS (output follows)

# /etc/default/rcS
# Default settings for the scripts in /etc/rcS.d/
# For information about these variables see the rcS(5) manual page.
# This file belongs to the "initscripts" package.
TMPTIME=0
SULOGIN=no
DELAYLOGIN=no
UTC=no
VERBOSE=no
FSCKFIX=no

Something is happening in the boot process that is changing the time it reads from the hardware clock to the incorrect time.
I know of no way to single step through boot and I don't think I'd want to. Ubuntu has no boot log other than dmesg.
That's why I'm baffled. I don't know where to look next for a resolution to this problem.

I'm pretty sure the reason for this problem is that I don't use GDM but just log in and start X from the command line. Server installs would be the same and they can't have the wrong time.

Maybe most server installs use some other distro. Considering the way I have the system set up maybe I should consider that myself.

Here are the entire contents of /var/log/boot:
(Nothing has been logged yet.)

Thanks for all the help so far.
 
Old 03-06-2008, 09:51 AM   #12
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
I'm pretty sure the reason for this problem is that I don't use GDM but just log in and start X from the command line. Server installs would be the same and they can't have the wrong time.
Are you saying the clock is correct before you start X?
 
Old 03-06-2008, 11:11 AM   #13
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Original Poster
Rep: Reputation: 15
explanation

The time is also incorrect before starting X.

However I know from my experience from a full Ubuntu install that GDM actually loads a bunch of stuff before it starts the X session.

I'm guessing that one of the things GDM may be doing is setting the time correctly.

My reason for this suspicion is that usually a quick web search on a given problem will find many pages of similar problems. Other than the UTC=no thing I seem to be totally alone here.

The standard install worked on this machine and the custom one does not. I'm guessing why.

The custom install was a standard full ubuntu install from the alternate cd. I then removed nautilus, metacity and GDM. After that I installed openbox. Since startx worked incorrectly I just type xinit at the command line after logging in.
 
Old 03-06-2008, 11:19 AM   #14
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Did you try tzselect utility to set your timezone again? What's in /etc/timezone?
 
Old 03-06-2008, 11:59 AM   #15
wyndetygre
Member
 
Registered: Feb 2008
Location: surf city, nc
Distribution: custom - ubuntu based
Posts: 37

Original Poster
Rep: Reputation: 15
oops

I had completely forgotten that I had Ubuntu installed on another drive. Usually when I install a new distribution I park it on an older drive in my box. That way I have a working system while I work out the bugs in the new system. Then I install it on the newer drive.

After booting to the other drive, running ntpdate and rebooting to the other drive the time was correct.

This eliminates everything except the ntp package:

Package: ntp (1:4.2.4p0+dfsg-1ubuntu2)
Network Time Protocol daemon and utility programs

NTP, the Network Time Protocol, is used to keep computer clocks accurate by synchronizing them over the Internet or a local network, or by following an accurate hardware receiver that interprets GPS, DCF-77, NIST or similar time signals.

This package contains the NTP daemon and utility programs. An NTP daemon needs to be running on each host that is to have its clock accuracy controlled by NTP. The same NTP daemon is also used to provide NTP service to other hosts.

I had synaptic completely remove this package but I suspect it still is operating.

The problem I was originally trying to solve is setting the time on the laptop from the desktop over my little lan.

Ntpdate will not work behind a proxy. So I thought I would sync it with the desktop.

I know the ntp package was messing up the time on both computers which is why I removed it.

I've run into this before on linux especially with network stuff. The package is removed but the scripts etc are not.

This leaves the system unstable.

Short of a complete reinstall I don't know how to fix it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
NTP time sync with windows 2000 AD time csghosh Linux - Enterprise 7 02-24-2012 03:46 PM
NTP Server giving central time instead of eastern time wjleon Linux - Networking 3 11-01-2007 04:04 PM
debian: Get time from ntp (network time protocol) servers checkmate3001 LinuxQuestions.org Member Success Stories 0 09-30-2007 06:36 PM
NTP sync up time sidra Linux - Networking 1 09-27-2007 09:07 PM
ntp time sync eyewittness Linux - Networking 2 08-11-2004 09:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration