How to configure a Linux machine to get time from an NTP server

Home > Search > How-to
  by

Use apt-get or yum to install the NTP daemon on the client PC.

[root@client1 ~]# yum install ntp

 

In the /etc/ntp.conf file, comment out the 4 pool NTP pool servers, and then add peer ntp.example.com. Replace ntp1.example.com with the actual hostname of your NTP server. Peer configures the client to use the NTP server for time.

#server 0.distro.pool.ntp.org iburst
#server 1.distro.pool.ntp.org iburst
#server 2.distro.pool.ntp.org iburst
#server 3.distro.pool.ntp.org iburst
peer ntp1.example.com

 

Start the NTP daemon, and ensure the daemon is active and running.

[root@server1 ~]# systemctl start ntpd
[root@server1 ~]# systemctl status ntpd

 

Configure ntp to automatically run after boot.

[root@server1 ~]# systemctl enable ntpd

 

The ntpq -p command can be used to ensure the machine is using your NTP server. The record that begins with the * special character is the primary NTP server, and the records that begin with + are the backup NTP servers.

[root@server1 ~]# ntpq -p
     remote             refid      st t when poll reach   delay   offset  jitter
================================================================================
*ntp1.example.com  198.60.22.240    2 u   21   64    0    0.000    0.000   0.000
+ntp2.example.com  198.60.22.240    2 u   21   64    0    0.000    0.000   0.000

 

Use the date command to verify the machine is getting the correct date and time from the NTP server.

[root@server1 ~]# date
Mon Jan 01 00:01:01 CDT 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