How to automatically sync your server time clock with rdate in CentOS 5.5 Print

  • 2

The linux command "rdate" is very useful to quickly sync your server time clock with an NTP (Network Time Protocol) Server.

There are a few options: rdate [-p] [-s] [-u] [-l] [-t sec] [host...]

-p : Print the time returned by the remote machine.

-s : Set the system time to the returned time.

-u : Use UDP instead of TCP as the transport.

-l : Use syslog to output errors (cron.warning) and output (cron.info)

-t : Set timeout in seconds for every attempt to retrieve date.

 

Step 1: Make sure you have rdate and cron installed

yum install rdate vixie-cron

 

Step 2: Pick a server to use to sync time with.

List of HOSTNAME's: http://tycho.usno.navy.mil/ntp.html

 

Step 3: Edit your cron and add a schedule to run the command as often as needed within reason.

(Generally once a day is acceptable)

Add the following to your cron: replace the HOSTNAME with one from the list above

0 6 * * * /usr/bin/rdate -s HOSTNAME 2>&1 >> /dev/null

NOTE: 0 6 * * * means: Check once at 6:00 AM every day


Was this answer helpful?

« Back