I don’t know why servers’ clocks tend to drift (if someone knows, please explain), but the fact is, they do. Having the wrong time on your server can be a problem for various reasons since time stamps are used in several decisions that the server has to make as well as for debugging and logging. Plus it’s just really annoying. In fact, it’s so important to me to know the right time that I wear a watch which synchronizes with an atomic clock in Colorado over radio waves three times a day. Maybe that’s going a little far, but it’s certainly not too much to ask of an expensive, high-end server to maintain the correct time.
As I was setting up a new server last night (whose time was hopeless off), I decided to experiment with “rdate”. rdate uses NTP, or Network Time Protocol, to get the time from a network, and either print it out or set it on the server. I have only used it on Linux and OS X, so I don’t know if it is supported on Windows, but I would image there is either a Windows equivalent, or you can get the actual rdate program with Cygwin (if you don’t use Cygwin, I highly recommend it).The next step was to find an NTP server that kept accurate time. I found a list of servers here:http://www.eecis.udel.edu/~mills/ntp/clock1a.htmlAlthough the list was last updated on May 8th, I only found a few that actually worked. I’ll save you the trouble and list them here:Washington DC area:
I found that the two servers in the DC area were exactly in synch with my watch (at least down to the second) while the two servers in Texas were about .5 seconds off. To get the time from an rdate server, type:
[wednesday:tmp]$ rdate -p tick.greyware.com
The last step was to set up a cron job (or on Windows, a scheduled task) to update the time on a regular schedule. To have rdate actually set the time on your server using the time from the network, use the “-s” flag:
[wednesday:tmp]$ rdate -s tick.greyware.com
(Note that you have to root to change the time on the server.)Now I have the time automatically synchronized daily on my new server. I just hope the time on the NTP server doesn’t start to wonder now, or the time on the atomic clock in Colorado, for that matter. Then I will really be lost.