Table of Contents
NTP ntpdate VS ntpd
Preface
For many application today correct time setting is crucial. According to this long time ago (in 1980’s) has benne NTP protocol invented at University of Delaware. Mentioned protocol is using several level architecture where each level is called Stratum X. In general we can say that as higher the Stratum number is as more hops we have to referral time source.
The goal of NTP protocol is to keep as accurate as possible the local time on your Server or PC. The reason is that many application are using time as min imput parameter. According to this it is important to keep it as aureate as possible.
NTPDATE
In the case that you are looking for one time synchronization of your time on your Server or PC with NTP server it is possible to use “ntpdate“ command.
In another words it can be root case for application failure running on this server, as it happen that this command will change the time from current to correct time in several seconds, what can mean that it can as well change the time backwards ( What is inacceptable for many applications) .
[root@NTP-Stratum-2 ~]# date # Check current OS time Tue Mar 18 09:33:26 UTC 2014 [root@NTP-Stratum-2 ~]# date 110212572003 # Change OS time Sun Nov 2 12:57:00 UTC 2003 [root@NTP-Stratum-2 ~]# date # Check if OS time was changed Sun Nov 2 12:57:01 UTC 2003 [root@NTP-Stratum-2 ~]# ntpdate -s time.nist.gov # Use NTP protocol for correcting of OS time [root@NTP-Stratum-2 ~]# date # Check the corrected OS time Tue Mar 18 09:33:39 UTC 2014
NTPD
In the case that you are looking for long term solution that will keep your local Server or PC time up to date NTPD is the right solution. It
NTPD demon will run on your Server or PC and it will periodically synchronize your local OS time with remote NTP server. This communication will use UDP/123 port.
[root@NTP-Stratum-2 ~]# date # Check current OS time Tue Mar 18 09:44:23 UTC 2014 [root@NTP-Stratum-2 ~]# date 110212572003 # Chaneg OS time Sun Nov 2 12:57:00 UTC 2003 [root@NTP-Stratum-2 ~]# /etc/init.d/ntpd start Starting ntpd: [ OK ] # Start NTPD [root@NTP-Stratum-2 ~]# ntpq -p # Check the offset of OS time to NTP servers remote refid st t when poll reach delay offset jitter ============================================================================== bianca.unknown. 195.113.144.238 2 u 1 64 1 13.863 3273580 2.260 iwik.org .INIT. 16 u - 64 0 0.000 0.000 0.000 kenny.oneemedia 193.79.237.14 2 u 1 64 1 14.044 3273580 1.527 2.ntp.tld.sk 194.160.23.2 2 u 2 64 1 12.471 3273580 0.000 [root@NTP-Stratum-2 ~]# ntpq -p # Check again the offset remote refid st t when poll reach delay offset jitter ============================================================================== +bianca.unknown. 195.113.144.238 2 u 32 64 1 14.279 0.390 1.988 iwik.org .STEP. 16 u - 64 0 0.000 0.000 0.000 +kenny.oneemedia 193.79.237.14 2 u 30 64 1 11.941 3.879 3.959 *2.ntp.tld.sk 194.160.23.2 2 u 27 64 1 11.500 1.434 0.374 [root@NTP-Stratum-2 ~]# date # Check the local OS time Tue Mar 18 09:45:29 UTC 2014