Sync time with ntp server – Linux


Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks.

Installing NTP:

In Centos/Fedora

$ yum install ntp

In Ubuntu/Debian

$ apt-get install ntp

Configuring NTP:

NTP uses UDP port 123 to sync time with NTP servers, either connecting out to another NTP server or accepting incoming connections.

If your iptables filtering incoming traffic on the main NTP server in your cluster you need to open port 123 to UDP traffic to allow the other servers to connect to it.

After installing NTP, daemon will started automatically. First you need to stoop ntp to sync time with ntp server.

To stop NTP use following command:

$ service ntpd  stop

To sync time with NTP server run following command:

$ ntpdate

To sync you can use any of the NTP servers specified in /etc/ntp.conf file or you can use

After running ntpdate you can start ntp server again that will sync date and time automatically.

To start NTP use following command:

$ service ntpd start

To restart NTP use following command:

$ service ntpd restart