How to sync datetime in Centos 7 with ntp

This tutorial helps you keep your server synchronized automatically with ntpd service.

First of all, we need update our system:

sudo yum update -y

Next, install ntp:

sudo yum install -y ntp

Next, enable ntpd service run at startup

systemctl enable ntpd

Now check current status of ntpd

systemctl status ntpd

Restart ntpd if need:

systemctl restart ntpd

Check ntpd configuration at:

vi /etc/ntp.conf

Your pre-configured file will be something like this:

For more information about this file, see the man pages
 ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
 driftfile /var/lib/ntp/drift
 Permit time synchronization with our time source, but do not
 permit the source to query or modify the service on this system.
 restrict default nomodify notrap nopeer noquery
 Permit all access over the loopback interface.  This could
 be tightened as well, but to do so would effect some of
 the administrative functions.
 restrict 127.0.0.1
 restrict ::1
 Hosts on local network are less restricted.
 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
 Use public servers from the pool.ntp.org project.
 Please consider joining the pool (http://www.pool.ntp.org/join.html).
 server 0.centos.pool.ntp.org iburst
 server 1.centos.pool.ntp.org iburst
 server 2.centos.pool.ntp.org iburst
 server 3.centos.pool.ntp.org iburst

....

Now check your system date time with command:

date
Related:  Manual for cross-compiling a C++ application from Linux to Windows?

Leave a Reply

Your email address will not be published. Required fields are marked *