To make sure our servers time is always up to date we are going to install ntp package which enables our server to use NTP protocol for syncing your servers clock.
apt-get install ntp
If your data center or VPS provider offers an NTP service use their NTP server. Open up /etc/ntp.conf with nano and replace:
server 0.debian.pool.ntp.org iburst dynamic server 1.debian.pool.ntp.org iburst dynamic server 2.debian.pool.ntp.org iburst dynamic server 3.debian.pool.ntp.org iburst dynamic
You should have at least two servers in the
After saving the changes you have to restart the NTP service by running
invoke-rc.d ntp restart
invoke-rc.d is Debians shortcut to /etc/init.d/. You can run
/etc/init.d/ntp restart as well.
You can examine if the NTP server is working as expected if you run the
ntpq -p command:
example:~# ntpq -p
remote refid st t when poll reach delay offset jitter ============================================================================== zg1.ntp.CARNet. 184.108.40.206 2 u 58 64 3 7.157 106.619 4.158 zg2.ntp.CARNet. 220.127.116.11 2 u 57 64 3 7.677 25.934 4.792 morcic.RI.CARNe 18.104.22.168 2 u 58 64 3 11.796 26.527 7.751
After a while the reach column should have values greather that 0. Which means that the NTP servers we are pooling for time information are reachable.