Bootstrap FreeKB - NTP - Configure a Linux machine to get time from an NTP server
NTP - Configure a Linux machine to get time from an NTP server

Updated:   |  NTP articles

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

 

The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.

If your system is using systemd, use the systemctl command to ensure ntpd is running.

systemctl status ntpd

 

If your system is using init, use the chkconfig and service commands to ensure ntpd is running.

service ntpd status

 

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.

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.

date
. . .
Mon Jan 01 00:01:01 CDT 2016

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


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