NTP (Network Time Protocol) is used to ensure that the clock on your computer is correct. With newer, very time critical features, such as 2FA, this is important. Don’t worry though, it’s very easy to synchronise the time on your server, you just need to setup NTP.
How do I setup NTP?
Firstly, you’ll need to ensure your server is set to your local timezone. Follow this guide.
Now, install the NTP service – this is available in the standard CentOS repositories
[user@server] sudo yum -y install ntp
This will create the configuration file at /etc/ntp.conf
Use your favorite editor to check this, I always use nano.
[user@server] sudo nano /etc/ntp.conf
You need to check that there are some NTP servers from the NTP pool available (not commented out), and that your server is restricted to localhost. Look for the following lines:
restrict 127.0.0.1 restrict ::1 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
Ctrl+o to save and ctrl+x to exit
Now, we need to set NTP to run on startup
[user@server] sudo chkconfig ntpd on
And finally, start the service.
[user@server] sudo service ntpd start
Running ‘ps -faux | grep ntp’ should now show that NTP is running and keeping your clock extremely precise for you.
Next, you can verify which servers your clock is syncronising with using:
[user@server] ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *lond-web-1.spee 126.96.36.199 2 u 53 64 7 1.523 0.636 0.377 y.ns.gin.ntt.ne 249.224.99.213 2 u 56 64 7 0.658 -0.312 0.342 time.videxio.ne 188.8.131.52 2 u 50 64 7 1.624 0.197 0.315 x.ns.gin.ntt.ne 249.224.99.213 2 u 52 64 7 0.701 0.614 0.397