ntpd_vs_ntpdate
http://www.pool.ntp.org/zone/asia
http://www.pool.ntp.org/zone/cn
http://www.linuxquestions.org/questions/linux-networking-3/ntpdate-vs-ntpd-532260/
http://superuser.com/questions/444733/linux-ntpd-and-ntpdate-service
They do different things.
ntpdate
is what you might consider "one shot mode". It runs once and updates the clock if it receives a response from the remote ntp server.ntpd
runs continuously and adjusts the clock slightly to account for drift and to stay in sync with the remote ntp server.ntpd
(by default) will not make any adjustments greater than 2 seconds.
It's common to run ntpdate
at system boot to ensure the clock is in sync and then run ntpd
to keep it in sync. If for example when your computer boots, the clock is off by 3 seconds then ntpd
would assume that it's too great a jump to adjust, and therefore do nothing. Your system would then drift even further out of sync.
http://ae.koroglu.org/how-to-sync-time-properly-ntpdate-or-ntpd/
How to sync time properly: ntpdate or ntpd?
7th November 2013 by Ali Erdinç KöroğluPreviously I explained how to install chrooted NTP server, but the question is how you’re going to sync time of your server with a NTP server. There are two options: Ntpdate and Ntpd.
Ntpdate is for the one-time synchronization only.
Ntpd (network time protocol daemon) is for automatically sync system time with a remote reference time server.
There are many examples like adding cronjobs for ntpdate hourly, daily, weekly etc. The main difference between ntpd and ntpdate; ntpd will run all the time and continuously adjust the system time when clocks drift but ntpdate will not. Also keep in mind that ntpdate is deprecated as of September 2012.
So why we need ntpdate at all ?
In ancient ages it was important to get the system time before starting ntpd and usually done by ntpdate. Over time, ntpd evolved and no longer necessary to set the time before starting ntpd.
To sum up; if you’re running time specific operations like application servers, database servers, email servers, clusters etc. ntpd is what you need.
Installation
Since NTP package is in the base repository no need to add extra repository.
yum install ntp chkconfig ntpd on |
Configuration
driftfile /var/lib/ntp/drift restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1 server 192.168.100.254 # your NTP server server 0.tr.pool.ntp.org # region releated ntp.org server server ntp.ulakbim.gov.tr # local authority |
Since this will not be a ntp server for other so no need to listen on all interfaces.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g -I eth0" |
Starting..
[root@cache ~]# /etc/init.d/ntpd start Starting ntpd: [ OK ] |
NTP query result and network time synchronisation status
[root@cache ~]# ntpstat synchronised to NTP server (192.168.100.254) at stratum 4 time correct to within 108 ms polling server every 64 s [root@cache ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *192.168.100.254 82.94.167.75 3 u 5 64 377 0.276 -21.198 25.027 |
And as you see everything ok..
Nov 7 13:48:51 cache ntpd[44248]: ntpd 4.2.4p8@1.1612-o Fri Feb 22 11:23:27 UTC 2013 (1) Nov 7 13:48:51 cache ntpd[44249]: precision = 0.079 usec Nov 7 13:48:51 cache ntpd[44249]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled Nov 7 13:48:51 cache ntpd[44249]: Listening on interface #1 wildcard, ::#123 Disabled Nov 7 13:48:51 cache ntpd[44249]: Listening on interface #2 lo, ::1#123 EnabledNov 7 13:48:51 cache ntpd[44249]: Listening on interface #3 eth0, fe80::20c:29ff:febd:d65f#123 EnabledNov 7 13:48:51 cache ntpd[44249]: Listening on interface #4 eth1, fe80::20c:29ff:febd:d669#123 Disabled Nov 7 13:48:51 cache ntpd[44249]: Listening on interface #5 lo, 127.0.0.1#123 EnabledNov 7 13:48:51 cache ntpd[44249]: Listening on interface #6 eth0, 192.168.100.1#123 EnabledNov 7 13:48:51 cache ntpd[44249]: Listening on interface #7 eth1, 192.168.101.1#123 Disabled Nov 7 13:48:51 cache ntpd[44249]: Listening on routing socket on fd #29 for interface updates Nov 7 13:48:51 cache ntpd[44249]: kernel time sync status 2040 |