Setting up ntpd on FreeBSD


Ntpd is a daemon that fetches the current time from servers on the internet. It assures correct time and date for your system, which is important for cronjobs and timetags on files.

Step 1:

Ntpd is preinstalled on every FreeBSD install, so we just need to edit the config file. It’s located in /etc/ntp.conf. Edit it as root with your preferred editor or use:

vi /etc/ntp.conf

You might find a lot of comments in this file, all of which you can safely ignore. Beneath the comments we’ll append our ntp server locations. On the ntp pool project you will find a complete list of servers. We also need to tell our system where our driftfile is, as it stores the difference between our system clock and the external ones. Once you’ve found your servers, create a file that looks like this:


driftfile /var/db/ntp.drift

This way ntpd uses up to four of the servers in the pool and knows were the driftfile is. Be sure to use servers from your own country or at least ones that are close by ping so the delay stays small.

Step 2:

Now we need to set the correct timezone. Go to /usr/share/zoneinfo/ and find your closest locality. Then you create a symbolic link as root to our localtime which is done this way:

cp /usr/share/zoneinfo/Europe/Zurich /etc/localtime

This sets my timezone to Central Europe. You can use date to check if everything worked properly.

Step 3.1:

If your system clock is more than a half hour apart from the current time, we need to set it by using ntpdate since ntpd doesn’t correct for such vast differences. Grab a server close to you from your ntp.conf file and issue this command as root:


This grabs the correct time from a timeserver, in this case one from Switzerland, and uses it as your system time.

Step 3.2:

We want ntpd to start up every time the server is booted so we need to append as root the following to /etc/rc.conf:


We can start up ntpd by issuing this command as root:

/etc/rc.d/ntpd start

Now top should be showing you the process ntpd and our work is done.

This entry was posted in Unix and tagged , , , . Bookmark the permalink.