NTP Service Running On Local Host Does Not Sync System Time

Home » CentOS » NTP Service Running On Local Host Does Not Sync System Time
CentOS 6 Comments

Hi List

I have ntp running as a service on a PC, with the expectation that it would keep time in synch to my ntp server.

However, while I can manually update the time using “ntpdate -u …”, I find that if I manually force the wrong time, the ntpd service does not automatically re-synch the system time with the ntp server:

– Current time:

[admin@lol ~]# date Wed Jan 27 10:54:21 AST 2016

– Force wrong time:

[admin@lol ~]# date -s 09:29
Wed Jan 27 09:29:00 AST 2016

– Restart ntp service:

[admin@lol ~]# service ntpd restart Shutting down ntpd: [ OK ]
Starting ntpd: [ OK ]

– Time not synched (even after about 10 minutes)

[admin@lol ~]# date Wed Jan 27 09:35:52 AST 2016

– use ntpdate -u to force synch:

[admin@lol ~]# ntpdate -u time.lol.com
27 Jan 11:02:28 ntpdate[18570]: step time server 172.16.100.13 offset
5154.859809 sec
[osadmin@test-till ~]#

[admin@lol ~]# date Wed Jan 27 11:03:09 AST 2016

I’m not sure if this is a configuration issue with ntp (ntp.conf looks fine, as well as /etc/sysconfig/ntpd.conf (pasted below).

/etc/ntp.conf:

restrict default nomodify notrap nopeer noquery restrict 127.0.0.1
restrict ::1
server time.lol.com driftfile /var/lib/ntp/drift

/etc/sysconfig/ntpd”

# Drop root to id ‘ntp:ntp’ by default. OPTIONS=”-x -u ntp:ntp -p /var/run/ntpd.pid”
# Set to ‘yes’ to sync hw clock after successful ntpdate SYNC_HWCLOCK=yes
# Additional options for ntpdate NTPDATE_OPTIONS=””

6 thoughts on - NTP Service Running On Local Host Does Not Sync System Time

  • ntpd won’t make drastic changes in the time, if its too far off. its designed to stabilize the clock by making small changes in speeding it up or slowing it down, and not ‘staircase’ setting it absolutely.

    IMHO, ntpdate -u should be run before starting ntpd so the clock is close to spot on up front, I have sometimes added this to the
    /etc/init.d/ntp scripts. with systemd, this woudl be trickier to implement, maybe a seperate ‘service’ thats runs the ntpddate -u and exits, which the ntpd service depends on being run first? I dunno, I
    haven’t really spent the time to grok systemd thoroughly yet.

  • Or of course reading the man page for ntpd it can be seen that the simplest answer is to use the -g option

    http://linux.die.net/man/8/ntpd

    This can be added in /etc/sysconfig/ntpd – the appropriate config file for such a thing.

    Hacking the init scripts is a terribly fragile thing that will break on the next NTP package update as they are explicitly not marked as config files and will be ‘fixed’.

  • It’s best practice to have a reasonable pool of sources (3, 5 or 7
    depending on how many false tickers you want to be able to cope with)
    but it can run against a single source, with the understanding that it has to trust it as real time since there’s nothing to compare it to.

  • In article <56A88188.6070808@hogranch.com>, John R Pierce wrote:

    You don’t need to do that. If you have one or more ntp servers listed in /etc/ntp/step-tickers, the startup scripts will do it for you automatically. In C5 the ntpd script does it. In C6 you have to do “chkconfig ntpdate on” too, as it is separate from the ntpd script. In C7 i have no idea :-)

    Cheers Tony