NTP is an internet protocol used to synchronize the clocks of computers to a time reference.
NTP can be installed via your operating systems repository and the standard “ntpd” package will provide you with a script to synchronise the time manually (or via cron), as well as a daemon which will run on the server and keep the time up to date constantly.
Once you have NTP installed you can test that the time servers can be queried correctly. To test against the UK NTP time server you can run the following command:
ntpdate -q uk.pool.ntp.org
This will show you how out of sync your clock is and display an offset in the last line, for example : “offset -0.000993 sec”
You can then make the clock be updated as opposed to just queried by running the command :
ntpdate -s uk.pool.ntp.org
This can then be added to cron to keep the servers time up to date, or you can use the NTP daemon to keep the server running at the correct time – this is the better option, but for systems with lower resources they may not want another daemon constantly running.
To use the daemon you add the server pool to the /etc/ntp.conf file and start the daemon with the command :
/etc/init.d/ntpd start
Once the daemon is up and running you can view the ntp system’s current status by running the command :
ntpq -p