The simplest way to sync time using ntp.

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.
 
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.
 
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:

Code:
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.
 
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.
 
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:

Code:
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.

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

Code:
#----------ntp config
ntpd_enable="YES"
ntpd_sync_on_start="YES"
 
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. :D
 
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).
 
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.
 
There are plenty of times that I run a VM with FreeBSD and when I suspend my Laptop the date and time are not more updated. ntp can not synchronize due to high offset. Which command can I use without rebooting the VM?

Sorry I now noticed that the posts above are from 2010...
 
Add tinker panic 0 to /etc/ntp.conf.
Tried it, still required ntpd service restart
ntp.conf(5):
Rich (BB code):
[...]
       tinker  [allan  allan  |	 dispersion  dispersion	| freq freq | huffpuff
	       huffpuff	| panic	panic  |  step	step  |	 stepback  stepback  |
	       stepfwd stepfwd | stepout stepout]
	       This  command  can be used to alter several system variables in
	       very exceptional	circumstances.	It should occur	in the config-
	       uration file before any other configuration options.
Did you put the tinker directive at the top of the configuration file?

I also suggest you observe and wait for 3 minutes after the VM is wakened to see the tinker directive to "kick in", IIRC setting tinker panic 0 does not work immediately after a wake up of the VM.
 
As Erichans suggests, it takes a little while. Edit: I just measured the delay at 6 minutes on my notebook VM.

You can watch what's happening with ntpq -pn.

Also, just to cover all the bases, make sure you restart ntpd after changing the config file.
 
/etc/rc.resume actually restarts /etc/rc.d/ntpd. But that might not be the case for OpenNTPd or Chrony rc.d(8) scripts.

rc.resume:
Code:
files=`rcorder ${rcorder_opts} /etc/rc.d/* ${local_rc} 2>/dev/null`

for _rc_elem in $files; do
        debug "run_rc_script $_rc_elem resume"
        run_rc_script $_rc_elem resume
done

That 'resume' is defined in /etc/rc.d/ntpd:
Code:
ntpd_resume()
{
        run_rc_command restart
}
 
Back
Top