Networking

Tech Tip: Synchronize your Linux system's time with clockspeed

Not only can clockspeed update a system's clock from an NTP server, but it can also calculate clock drifts and manage the system time accordingly.

Most people who want to maintain an accurate computer clock use Network Time Protocol (NTP) to set their clocks to the same time as an atomic clock. NTP is a great way to ensure all of the computers on a network operate with an identical time, which helps with watching log files, scheduled automatic maintenance jobs, etc.

However, if you have a large network, NTP can create a fair amount of traffic to keep the clocks updated. It needs to run somewhat regularly to adjust for individual clock drifts on different computers. So unless you set up your own NTP server for the network, it can generate more traffic than you bargained for.

One alternative is D. J. Bernstein's clockspeed program. Not only can it update the system's clock from an NTP server, but it can also calculate clock drifts and manage the system time accordingly.

Using clockspeed, you should only need to synchronize with an NTP server infrequently after the initial configuration; it could be even as rarely as once a year.

To begin, download clockspeed from the Web, and compile and install it. Then, use the sntpclock tool to view the difference between the remote clock and the local clock, as shown below. (Replace 1.2.3.4 with the remote NTP server's IP address.)

# sntpclock 1.2.3.4 | clockview

This shows the current time as well as the time the NTP server displays. To update the local clock to the same time as the NTP server, execute the following:

# sntpclock 1.2.3.4 | clockadd

Next, run clockspeed as a daemon by adding the following to something like /etc/rc.d/rc.local.

clockspeed &

The Install file that comes with clockspeed provides further information for checking and adjusting your system clock after a few days and after a few weeks. This should synchronize your local clock with the remote clock within a few seconds per century. At that point, verifying the time once a year should be perfectly reasonable.

0 comments

Editor's Picks