Wednesday, April 1, 2015

Synchronize the system clock to Network Time Protocol (NTP) in CentOS/RHEL

PThe Network Time Protocol daemon (ntpd) program is a Linux operating system daemon. It sets and maintains the system time of day in synchronism with time servers (Mills).

Install NTP Daemon

Open terminal and type:

# yum install ntp

Or

# up2date ntp

Configuration

Now you need to set ntp server to ntpd can synchronize your local date time to server's one. Configuration file located in /etc/ntp.conf

# vi /etc/ntp.conf

By default, ntpd uses these server to do its job

server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
server 3.centos.pool.ntp.org

You can refer to http://www.pool.ntp.org/ and choose what server you want. After changes, save this file and start ntpd

Make ntpd run as service

By making ntpd run as service will make your PC's date time is synchronized every boot

# chkconfig ntpd on

Start ntpd

# service ntpd start

You can synchronize the system clock to an NTP server immediately with following command

# ntpdate pool.ntp.org

After synchronizing completed, check your date time again to make sure it worked

# date

Reference

No comments:

Post a Comment