How To Set the System Clock in FreeBSD and Keep It Updated

29 Aug 2004

It's definitely a good thing to have your system clock synch itself each time you reboot using a public NTP Timeserver. FreeBSD makes this a piece of cake.

First, you'll want to make sure your timezone is set correctly. Check /usr/share/zoneinfo for the correct time zone file, and copy it to /etc/localtime. I.e.:

bash-2.05b# cp /usr/share/zoneinfo/zonefilehere /etc/localtime

Once you've done that, you will need to make sure your date and time are set within at least a few minutes of the current date and time. To do this, use the date command:

bash-2.05b# date 0408290000

The date is in YYMMDDHHMM format, the clock being a 24 hour and not 12 hour clock. To make sure the date looks correct before moving on, just type date in again:

bash-2.05b# date Sun Aug 29 00:00:33 MDT 2004

Now that our timezone, date, and time are all set correctly, lets setup the NTP daemon to keep the system time synced-up.To do this, open /etc/rc.conf in your editor of choice, and add these lines:

ntpdate_enable="YES" ntpdate_program="ntpdate" ntpdate_flags="-b"

Replace with a server from a public NTP timeserver list which is near you (by number of network hops, not necessarily physical location). You'll need to Google for a list of these yourself. Voila!

Why did I do this? Well, my last post said it was posted at 5 something AM.. and we all know I would never get up that early.