# The simplest way to sync time using ntp.



## drp (Jul 24, 2010)

I've found tutorials and documentation on this, and have read about it before (when using Linux)... but if you know, what is the easiest way to install and use ntp for keeping the time in sync? I'm just wondering what the very simplest way is.


----------



## drp (Jul 24, 2010)

The easiest way I've ever seen to do it is using the clock of whichever desktop environment you're using, when it has the option of using NTP. Whether or not it clashes with other NTP setups or whatever else, I have no idea. I'm a little confused about the different options there are, and whether or not they conflict with each other, etc.


----------



## gordon@ (Jul 24, 2010)

In FreeBSD, I recommend you use both ntpdate and ntpd. ntpdate will set the clock when you first boot so it's close enough that ntpd will work with it.

You can just add the following to /etc/rc.conf:


```
ntpd_enable="YES"
ntpdate_enable="YES"
```

Then read through /etc/ntp.conf. It's pretty well documented so it should be pretty obvious what to set.


----------



## gilinko (Jul 24, 2010)

Or install openntpd from ports, which is much simpler and in my opinion works a lot better then the native ntpd daemon. No need to worry about stratum or anything else like that, just point it at a ntp server and let it go. However do use ntpdate to set the time and date on boot, to always have a good clock to start with.


----------



## rbelk (Jul 24, 2010)

gordon@ said:
			
		

> In FreeBSD, I recommend you use both ntpdate and ntpd. ntpdate will set the clock when you first boot so it's close enough that ntpd will work with it.
> 
> You can just add the following to /etc/rc.conf:
> 
> ...



Gordon, I've only use ntpd only at startup. I guess it doesn't make a difference though.


```
#----------ntp config
ntpd_enable="YES"
ntpd_sync_on_start="YES"
```


----------



## drp (Jul 24, 2010)

> ntpd_enable="YES"
> ntpd_sync_on_start="YES"


Thanks, rbelk, that works for me. When I tried it the other way, it was giving me errors saying "hostname nor servname provided" and "cannot find host" or "cannot resolve host" or something along those lines. Now it's working fine.


----------



## drp (Jul 24, 2010)

That's just what I was looking for, that's the simplest thing I can think of doing.


----------



## gordon@ (Jul 24, 2010)

Ah, looks like ntpd_sync_on_start does the same thing that ntpdate does for you. Good to know (to avoid having to fork an additional process during bootup).


----------



## phoenix (Jul 24, 2010)

gilinko said:
			
		

> Or install openntpd from ports, which is much simpler and in my opinion works a lot better then the native ntpd daemon. No need to worry about stratum or anything else like that, just point it at a ntp server and let it go. However do use ntpdate to set the time and date on boot, to always have a good clock to start with.



*openntpd_flags="-s"* will tell openntpd to sync the clock when it starts (jumping the clock by X seconds if needed), then keep the clock in sync afterward.


----------

