LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-26-2012, 07:14 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Rep: Reputation: 34
Cant get time correctly syncd


Hello,

I do the following on my CentOS server :

bash-3.2# rm /etc/localtime

bash-3.2# ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime

bash-3.2# /usr/sbin/ntpdate 0.be.pool.ntp.org

I get time :
26 Sep 14:09:52 ntpdate[2074]: step time server 193.104.37.238 offset 133.148363 sec

While time should be :
wo sep 26 14:12:18 CEST 2012
(correct time on my Acer Fedora laptop)

There is more than 2 minutes difference. How come ??
 
Old 09-26-2012, 07:21 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
in such cases I would try it several times and also with several ntp servers.
 
Old 09-26-2012, 10:33 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
my CentOS bacula host has this cron entry:
Code:
*/15 * * * * ntpdate pool.ntp.org
to correct a TZ "drift".
 
Old 09-26-2012, 11:16 AM   #4
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
You could also try ntpd which continuously syncs the time.
 
Old 09-26-2012, 11:18 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Quote:
Originally Posted by Habitual View Post
my CentOS bacula host has this cron entry:
Code:
*/15 * * * * ntpdate pool.ntp.org
to correct a TZ "drift".
Not really the best method. Running ntpdate via cron will just force a clock correction but will not compensate for drift. By running NTP the system clock drift error will be calculated and it can maintain synchronization nominally within one millisecond.

jonaskellens,
The time in the message is not the corrected time. Your offset was 133 seconds which is 2 minutes 13 seconds which if your Fedora laptop was time synched should be reasonable. Run the date command on both computers again or compare the times on the desktop if running a GUI.
 
Old 09-27-2012, 02:28 AM   #6
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
Date on Fedora laptop :

[Jonas@jonas ~]$ date
do sep 27 09:25:27 CEST 2012

Date on CentOS server before sync :

bash-3.2# date
do sep 27 09:23:20 CEST 2012

Date on CentOS server after sync :

bash-3.2# /usr/sbin/ntpdate pool.ntp.org
27 Sep 09:23:27 ntpdate[17983]: step time server 83.98.201.134 offset 130.359327 sec
bash-3.2# /usr/sbin/ntpdate 0.be.pool.ntp.org
27 Sep 09:23:32 ntpdate[17984]: step time server 91.183.56.68 offset 130.356664 sec
bash-3.2# date
do sep 27 09:23:34 CEST 2012

Date on Fedora on laptop :

[Jonas@jonas ~]$ date
do sep 27 09:25:50 CEST 2012

Still a difference...
 
Old 09-27-2012, 02:48 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Can you try to change the time by hand, and run ntpdate again?
 
Old 09-27-2012, 07:08 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Is the Fedora laptop running ntp or are you using ntpdate?

Post the output using the -d option
ntpdate -d pool.ntp.org
 
Old 09-27-2012, 07:58 AM   #9
ermoreno
LQ Newbie
 
Registered: May 2009
Location: San Antonio, Texas
Distribution: AIX, RHEL
Posts: 8

Rep: Reputation: 0
There is another file I usually modify on my systems.

[root@Blah sysconfig]# cat /etc/sysconfig/clock
ZONE="America/Chicago"
UTC=true
ARC=false
 
Old 09-28-2012, 03:27 AM   #10
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
bash-3.2# cat /etc/sysconfig/clock
# The ZONE parameter is only evaluated by system-config-date.
# The timezone of the system is defined by the contents of /etc/localtime.
ZONE="Europe/Brussels"
UTC=false
ARC=false



bash-3.2# /usr/sbin/ntpdate -d pool.ntp.org
28 Sep 10:23:36 ntpdate[8283]: ntpdate 4.2.2p1@1.1570-o Fri Nov 18 13:21:21 UTC 2011 (1)
Looking for host pool.ntp.org and service ntp
host found : sip.dicode.nl
transmit(91.148.192.49)
receive(91.148.192.49)
transmit(91.148.192.49)
receive(91.148.192.49)
transmit(91.148.192.49)
receive(91.148.192.49)
transmit(91.148.192.49)
receive(91.148.192.49)
transmit(91.148.192.49)
transmit(83.98.201.134)
receive(83.98.201.134)
transmit(83.98.201.134)
receive(83.98.201.134)
transmit(83.98.201.134)
receive(83.98.201.134)
transmit(83.98.201.134)
receive(83.98.201.134)
transmit(83.98.201.134)
transmit(213.154.229.24)
receive(213.154.229.24)
transmit(213.154.229.24)
receive(213.154.229.24)
transmit(213.154.229.24)
receive(213.154.229.24)
transmit(213.154.229.24)
receive(213.154.229.24)
transmit(213.154.229.24)
transmit(213.136.0.252)
receive(213.136.0.252)
transmit(213.136.0.252)
receive(213.136.0.252)
transmit(213.136.0.252)
receive(213.136.0.252)
transmit(213.136.0.252)
receive(213.136.0.252)
transmit(213.136.0.252)
server 91.148.192.49, port 123
stratum 2, precision -20, leap 00, trust 000
refid [91.148.192.49], delay 0.02696, dispersion 0.00006
transmitted 4, in filter 4
reference time: d40fd680.e5f50090 Fri, Sep 28 2012 9:55:44.898
originate timestamp: d40fdd87.2e4616ce Fri, Sep 28 2012 10:25:43.180
transmit timestamp: d40fdd08.87605ab3 Fri, Sep 28 2012 10:23:36.528
filter delay: 0.02721 0.02707 0.02724 0.02696
0.00000 0.00000 0.00000 0.00000
filter offset: 126.6513 126.6513 126.6514 126.6512
0.000000 0.000000 0.000000 0.000000
delay 0.02696, dispersion 0.00006
offset 126.651255

server 83.98.201.134, port 123
stratum 2, precision -20, leap 01, trust 000
refid [83.98.201.134], delay 0.02678, dispersion 0.00000
transmitted 4, in filter 4
reference time: d40fdd1b.ae14abe2 Fri, Sep 28 2012 10:23:55.680
originate timestamp: d40fdd87.6126b311 Fri, Sep 28 2012 10:25:43.379
transmit timestamp: d40fdd08.ba4b44a1 Fri, Sep 28 2012 10:23:36.727
filter delay: 0.02687 0.02681 0.02678 0.02681
0.00000 0.00000 0.00000 0.00000
filter offset: 126.6512 126.6511 126.6511 126.6511
0.000000 0.000000 0.000000 0.000000
delay 0.02678, dispersion 0.00000
offset 126.651198

server 213.154.229.24, port 123
stratum 2, precision -19, leap 00, trust 000
refid [213.154.229.24], delay 0.02748, dispersion 0.00002
transmitted 4, in filter 4
reference time: d40fdab3.50f91503 Fri, Sep 28 2012 10:13:39.316
originate timestamp: d40fdd87.952c8340 Fri, Sep 28 2012 10:25:43.582
transmit timestamp: d40fdd08.ee3a4b55 Fri, Sep 28 2012 10:23:36.930
filter delay: 0.02765 0.02780 0.02748 0.02763
0.00000 0.00000 0.00000 0.00000
filter offset: 126.6510 126.6511 126.6510 126.6510
0.000000 0.000000 0.000000 0.000000
delay 0.02748, dispersion 0.00002
offset 126.651092

server 213.136.0.252, port 123
stratum 1, precision -19, leap 00, trust 000
refid [PPS], delay 0.02750, dispersion 0.00002
transmitted 4, in filter 4
reference time: d40fdd51.7c5ca387 Fri, Sep 28 2012 10:24:49.485
originate timestamp: d40fdd87.c83685a3 Fri, Sep 28 2012 10:25:43.782
transmit timestamp: d40fdd09.215a3a08 Fri, Sep 28 2012 10:23:37.130
filter delay: 0.02780 0.02753 0.02759 0.02750
0.00000 0.00000 0.00000 0.00000
filter offset: 126.6509 126.6508 126.6508 126.6508
0.000000 0.000000 0.000000 0.000000
delay 0.02750, dispersion 0.00002
offset 126.650831

28 Sep 10:23:37 ntpdate[8283]: step time server 213.136.0.252 offset 126.650831 sec

bash-3.2# date
vr sep 28 10:23:41 CEST 2012
 
Old 09-28-2012, 04:30 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
I asked it: can you modify the time by hand? I think ntpdate does not set anything, just displays the offset. Try to set another offset (probably hours) and check it again
 
Old 09-28-2012, 06:33 AM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
ntpdate can be used to set the clock. With older versions of NTP it was necessary to run ntpdate first due to the fact that if the time difference was more then 1024 seconds ntp would quit assuming there was a problem.

You can force the time to be set with the -b option i.e.
ntpdate -b pool.ntp.org
 
Old 09-29-2012, 03:22 AM   #13
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
Forcing did not help :

Code:
bash-3.2# date
za sep 29 10:18:12 CEST 2012
bash-3.2# /usr/sbin/ntpdate -b pool.ntp.org
29 Sep 10:18:29 ntpdate[32303]: step time server 83.98.201.133 offset 123.112925 sec
bash-3.2# date
za sep 29 10:18:31 CEST 2012
There is still a difference of about 2 minutes...
 
Old 09-29-2012, 12:12 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Is this a real or virtual machine?
 
Old 10-01-2012, 02:43 AM   #15
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 690

Original Poster
Rep: Reputation: 34
This is a VM, VMware if I'm not mistaken...

Could this be the problem ? I have never had the problem that time on the VM was dependant on the host.
 
  


Reply



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
[SOLVED] Wicd won't install correctly/run correctly (64-bit Slackware 13) bgraybr Slackware 3 04-01-2010 06:57 PM
why does strptime (c++) seem to not correctly parse date/time string???? lxvor Programming 2 02-08-2010 05:08 PM
Date/Time not updating correctly. PeteBass Linux - Software 1 05-30-2007 08:48 AM
Apache server: Displays site correctly first time, than source on refresh. skidrash Linux - Networking 10 09-29-2004 12:59 PM
How to correctly set date/time? Jakerohs Linux - General 5 01-08-2004 03:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:01 AM.

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