NTP – Network Time Protocol allows for automatic and precise time synchronization over the network. There are many problems that can be caused by incorrect time – starting from logs confusions and going to software locks due to file timestamps. Configuring NTP is very easy. Just install the ntp RPM that comes with Red Hat or Fedora Linux (or a number of other Linux distributions) and use one of the two modes described below.
- Full blown NTP server. In this mode, you’ll have to edit
/etc/ntp.conf
to specify a number of NTP servers to synchronize time from, as well as a lit of machines that can synchronize time with your server. Usually you’d want to have only one full blown NTP servers per network. - Simple NTP client. This is even easier to configure than the previous mode. All you have to do is add these two commands to your scheduler (cron or similar) to execute hourly.
/usr/sbin/ntpdate -s ntp_server_ip_or_hostname /sbin/hwclock -w
While modern computers are very smart and fast, they don’t have any special skills at keeping the time precisely correct. Internal timers get offset by power cuts, CPU usage bursts, and things like that. The daily changes are small, but when left unattended for a longer period of times, clocks can run ahead or stay back for as long as days!
Here is a log record from one of the servers in our office:
21:01:01 ... ntpdate[...]: ... offset 0.250427 sec 22:01:00 ... ntpdate[...]: ... offset 0.251682 sec 23:01:01 ... ntpdate[...]: ... offset 0.251269 sec 00:01:01 ... ntpdate[...]: ... offset 0.251013 sec 01:01:01 ... ntpdate[...]: ... offset 0.250451 sec 02:01:01 ... ntpdate[...]: ... offset 0.250061 sec 03:01:01 ... ntpdate[...]: ... offset 0.250239 sec 04:01:01 ... ntpdate[...]: ... offset 0.250313 sec 05:01:00 ... ntpdate[...]: ... offset 0.250112 sec 06:01:01 ... ntpdate[...]: ... offset 0.250554 sec 07:01:01 ... ntpdate[...]: ... offset 0.250691 sec 08:01:01 ... ntpdate[...]: ... offset 0.249850 sec 09:01:01 ... ntpdate[...]: ... offset 0.250418 sec 10:01:01 ... ntpdate[...]: ... offset 0.250070 sec 11:01:01 ... ntpdate[...]: ... offset 0.250488 sec
As you can see, this machine’s time inconsistencies are as large as quarter of a second per hour, which can result in 6 seconds per day (24 hours). This alone can cause noticable slowdowns in software that counts on time being always correct.
P.S.: There are NTP implementations for other operating systems as well. Google is your friend.