install ntp (network time protocol) server to synchronize time
$ sudo yum install ntp
Now follow this steps:
- first go to official http://www.pool.ntp.org/en/
- choose your Continent area where the server physically is located
- then search for your Country location
For United Sates:
server 0.us.pool.ntp.org server 1.us.pool.ntp.org server 2.us.pool.ntp.org server 3.us.pool.ntp.org
go to ntp config file
$ sudo vi /etc/ntp.conf
Uncomment initials:
#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
copy new United States to config and start
$ sudo systemctl start ntpdate
$ sudo systemctl enable ntpdate
$ sudo systemctl status ntpdate
run this
$ sudo ntpdate us.pool.ntp.org
check the date-time and match it with your cell phones!
$ timedatectl
Local time: Wed 2015-09-09 09:31:09 CDT Universal time: Wed 2015-09-09 14:31:09 UTC Timezone: America/Chicago (CDT, -0500) NTP enabled: no NTP synchronized: no RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2015-03-08 01:59:59 CST Sun 2015-03-08 03:00:00 CDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2015-11-01 01:59:59 CDT Sun 2015-11-01 01:00:00 CST
Since NTP enabled is no above, you can enable it like this (it will ask for your root password)
$ timedatectl set-ntp yes
then check out date-time again
$ timedatectl
Local time: Wed 2015-09-09 09:40:37 CDT Universal time: Wed 2015-09-09 14:40:37 UTC Timezone: America/Chicago (CDT, -0500) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2015-03-08 01:59:59 CST Sun 2015-03-08 03:00:00 CDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2015-11-01 01:59:59 CDT Sun 2015-11-01 01:00:00 CST
if you want to restart ntp, then you need to first unrelate ntp from timedatectl
$ timedatectl set-ntp no
$ sudo systemctl restart ntpdate
$ sudo systemctl enable ntpdate
$ sudo ntpdate us.pool.ntp.org
$ timedatectl set-ntp yes
make sure your timezone is also correct
(please follow http://www.putorius.net/2015/04/setting-time-and-date-in-red-hat-7.html to play with timedatectl command)
i.e. list all the timezones just for curiosity
$ timedatectl list-timezones
you can also check the date simply like this
$ date
Wed Sep 9 09:47:35 CDT 2015
2 thoughts on “CONFIGURE NTP ON CENTOS 7”