Synchronize to an NTP server using the NTPDATE command in Linux

Home > Search > Linux commands
  by

The ntpdate command can be used if the NTP server is NTPd. The ntpdate will produce no server suitable for synchronization found if the NTP server is not NTPd. For example, if the NTP server is Chrony, the ntpdate command will produce errors.

Use apt-get or yum to install the ntpdate utility.

[root@server1 ~]# yum install ntpdate

 

Configure ntpdate to automatically run after boot.

[root@server1 ~]# systemctl enable ntpdate

 

The ntpdate command without any options can be used to determine if the client machine is synchronized with an NTPd server. In this example, the client machine is not synchronized with an NTPd server.

[root@client1 ~]# ntpdate
19 Apr 17:06:46 ntpdate[7219]: no servers can be used, exiting

 


Test the connection to an NTPd server

The  -q (query) option can be used to verify that you are able to connect to a NTPd server. In this example, the client is able to connect to ntp1.software.eng.us.

[root@client1 ~]# ntpdate -q ntp1.example.com
server 192.168.0.119, stratum 3, offset -0.000526, delay 0.02586
8 Nov 09:24:01 ntpdate[25468]: adjust time server 192.168.0.119 offset -0.000526 sec

 


Synchronize to an NTP server

Use the ntpdate command followed by the hostname or IP address of an NTPd server can be used to configure a client to use the target NTPd server. In this example, the client will use ntp1.software.eng.us as the NTPd server.

[root@client1 ~]# ntpdate ntp1.software.eng.us
8 Nov 09:24:01 ntpdate[25468]: adjust time server 192.168.0.119 offset -0.000526 sec

 

The ntpstat command without any options confirms that client is synchronized with the NTPd server.

[root@server1 ~]# ntpstat
synchronised to NTP server (192.168.0.9) at stratum 3 
   time correct to within 17 ms
   polling server every 1024 s

 

The date command produces the time according to the NTPd server.

[root@server1 ~]# date
Tue Nov 8 09:30:02 CST 2016

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments