Geek Style

Babak Farrokhi’s e-presence

Syncing clock in FreeBSD

without comments

Keeping accurate time on a host (either a server or a workstation) is important because:

1- You need to know accurately when you should go for lunch or back home
2- You need accurate time in your event log files for further analysis
3- Many programs need to have the correct date and time to function (e.g. MTA)
4- You need correct timestamps on your files

Given above facts, you will need to enable NTP on your hosts and keep your system clock in sync with public time servers.

First you should make sure that your timezone setting is correct. The latest timezone information can be updated by installing “zoneinfo” port from /usr/ports/misc/zoneinfo:


# cd /usr/ports/misc/zoneinfo/
# make install clean

and run tzsetup(8) to make sure you have selected the correct timezone.

Now, to enable automatic time sync during system startup, you need to add a few lines to your /etc/rc.conf file:

ntpdate_enable="YES"
ntpdate_flags="-b pool.ntp.org"

This will make your system to sync the clock upon startup. I use NTP pool at “pool.ntp.org” that suggests a NTP server from a large pool of available time servers. However you may use your favorite/local NTP server.

You can also synchronize your time manually by invoking ntpdate(8) from command line, passing an NTP server address to it:

# ntpdate time.nist.gov

Written by Babak Farrokhi

September 27th, 2008 at 11:21 pm

Posted in OS

Tagged with

Leave a Reply