NTP — Keeping your clock in sync

One of the most insane things about working in the unix world is that it complains when the system clock on your computer is wrong. There is nothing more disturbing then when you create a tarball on another machine and extract it on yours and it complains that the files were created in the future.

A great way to deal with this problem is a system called ntp, network time protocol.

Network Time Protocol (RFC-1305), or more commonly known as NTP is pretty simple to setup, most OS’s are simply an RPM or ports tree install away.

(freebsd)
Connect to your machine and su - to root, then:

# cd /usr/ports/net/ntp
# make

# make install
# rehash

once thats done, simply run:

# ntpdate time.nist.gov
5 Nov 19:46:40 ntpdate[46439]: step time server 192.43.244.18 offset -2.467839 sec
#

This will update your server to the current time.

My suggestion is to set this up as a nightly cronjob,

# vi /etc/crontab

and add the line:

0 2 * * * root /usr/sbin/ntpdate time.nist.gov > /dev/null

and restart cron (

# killall -HUP cron

And you should be good to go!

Leave a Comment