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

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

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to sync the time zone (Linux)

On a VPS server, you don't have access to control the hardware clock directly. To detach your...

How to add the remi repository to CentOS 5.8 / RHEL 5.8 / Redhat

If you are looking for the latest rpm packages for CentOS 5.8 / RHEL / Redhat, the remi...

Configuring Nameservers (DNS) for Outside Domains

If you are not buying a domain from us you will need to manaully configure your nameservers (DNS)...

How to run Varnish Reverse Cache Proxy in CentOS 5.5

HTTP Accelerators have been around for years.  In 2006, Varnish was introduced and unlike...

cPanel Log Locations

cPanel Installation Logs: Code: /var/log/cpanel-install-thread0.log Apache: Code:...