Search Engine: Elastic

Article ID: 125828, created on Jun 11, 2015, last review on Apr 19, 2018

  • Applies to:
  • Virtuozzo containers for Linux
  • Operations Automation

Question

How do I configure an NTP (Network Time Protocol) client to keep time on the servers synced?

Answer

The Network Time Protocol (NTP) is used to synchronize a computer's time with another reference time source. Under CentOS / RHEL you can use NTP or OpenNTPD server software. Both package provide client and server software programs for time synchronization. Steps below will help to perform NTP installation and configuration.

The ntp package contains utilities and daemons that will synchronize your computer's time to Coordinated Universal Time (UTC) via the NTP protocol and NTP servers. The ntp package includes ntpdate (a program for retrieving the date and time from remote machines via a network) and ntpd (a daemon which continuously adjusts system time).

  1. Install the ntp package:

    # yum install ntp
    
  2. To configure the client open /etc/ntp.conf file, enter:

    # vi /etc/ntp.conf
    

    Make sure the following line exists:

    server ntp.server.com
    

    Where ntp.server.com is the hostname or IP address of the site NTP server. If your ntp server is located at 192.168.1.5, enter server 192.168.1.5. You can also use public ntp server located at ntp.org.

  3. Enable service for autostart and launch it:

    # chkconfig ntpd on
    # service ntpd start
    

    for RH/Centos 7 release, use

    # systemctl start ntpd
    

You can also run ntpd using cron:

# echo '30 * * * * root /usr/sbin/ntpd -q -u ntp:ntp' > /etc/cron.d/ntpd

The above instructs crond to run ntpd and after setting the clock just exit, and the -u option instructs it to run as the ntp user.

2897d76d56d2010f4e3a28f864d69223 e8e50b42231236b82df27684e7ec0beb d02f9caf3e11b191a38179103495106f 0efe2234e2ce513f2186f26c68447702 5356b422f65bdad1c3e9edca5d74a1ae caea8340e2d186a540518d08602aa065 e12cea1d47a3125d335d68e6d4e15e07

Email subscription for changes to this article
Save as PDF