Using “rdate” to Keep Your Server’s Time Accurate

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:

  • nist1-dc.glassey.com
  • 205.188.185.33

Texas:

  • tick.greyware.com
  • tock.greyware.com

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.

2 Responses to Using “rdate” to Keep Your Server’s Time Accurate

  1. PaulH says:

    i’m sort of anal about time keeping on my servers too, i’d time correct every 4 hours. at one time i had a trimble GPS base station in my office (before SA was turned off) from which i feed time into one of my servers & used Tardis on the other servers & workstations. When clinton turned off SA, we no longer had a need for a static base station for general SA removal so i switched completely to Tardis. it has a list of servers it cycles thru if one goes down.if you want reliability, the US Naval Observatory http://tycho.usno.navy.mil/ntp.html is probably the best bet.

  2. Pete Freitag says:

    Hi Christian,You will find more NTP servers that allow you to connect, if you look on the stratum2 page: http://www.eecis.udel.edu/~mills/ntp/clock2a.htmlMost of the stratum1 servers only allow stratum2 servers and their local network to connect.