Nearing the End

rdate versus ntpd

I've had trouble getting ntpd to start correctly on my Linux box. It's pathetic because I've made a couple of attempts and this has gone on for years.

Today I found a suggestion to use rdate instead. Here's how I did it. I don't know if it's perfect but it's fast, easy and my clock is reasonable accurate now. I'd rather have sophisticated ntpd than crude rdate because ntpd is careful to only make smooth gradual changes to the clock. I'm only suggesting rdate if you're like me, unable to get the ntpd process to start properly and remain running.

  1. Login as root
  2. Run "crontab -e"
  3. Enter the following. The top section is just a block of comments describing the file format. The last line is all you really need.
  4. Save the file.
#   FIELD    VALUE
#   ------------------
#   minute   00 to 59
#   hour     00 to 23 (military time)
#   day      1 to 31
#   month    1 to 12
#   weekday  0 to 6 (0=Sunday) Note: Linux uses sun, mon..

0 3 * * * (rdate -s clock.psu.edu || rdate -s ntp.nblug.org || rdate -s sundial.columbia.edu) > /tmp/rdate.stdout 2> /tmp/rdate.stderr

This will run the rdate command to reset the system clock once a day at 3 am.

This is a sequence of three rdate commands. If the first one fails then the second one will be tried. Same for the third.

I got these three host names from the official list of ntpd hosts that are (1) in the US, (2) don't require notification and (3) support the rdate protocol.

The output of the command goes to files in /tmp. Both files will normally be empty. The time stamp on the files will confirm that cron is executing the command each day.

  • /tmp/rdate.stdout
  • /tmp/rdate.stderr

Links