0

Is there any way to make ntpd more aggressive? I have a computer without a hardware clock in it. If it looses Internet for long periods of time, the time offsets until it slowly gets back to normal once the Internet connection is back. How do I make this behaviour stricter? I'd like the clock to sync to perfection the very moment it has Internet access again.

PS: Even if this means problems could arise from e.g cron jobs.

Paolo
  • 131
  • 1
  • 1
  • 6

2 Answers2

0

ntpd will automatically do the right thing by default anyway; if your clock is more than 128 ms (the step threshold), it will step the clock, otherwise it will slew the clock.

If you want to change the step threshold, so that time will be stepped if your system is, say, 50 ms off, you can use the tinker step option in /etc/ntp.conf.

If you're really that worried about the time being back in sync the moment you are reconnected to the Internet, you might want to consider getting a machine with a hardware clock, or better still, a PPS time source.

Paul Gear
  • 115
  • 5
0

What is your operating system? Check via command line:

uname -a

See if this works in the command line:

sudo service ntp stop
sudo ntpdate -s time.nist.gov
sudo service ntp start

If it works then create a script at /etc/network/if-up.d/updatetime:

service ntp stop
ntpdate -s time.nist.gov
service ntp start

Give it the right permissions:

chmod +x /etc/network/if-up.d/updatetime

Make sure the network interface (wlan0, eth0, etc.) is listed in /etc/network/interfaces

JeremiahBarrar
  • 1,060
  • 9
  • 14
  • That's what I'm doing now, an yes it works, but I'd like to not have to stop the service and sync it. There must be a way to ask the clock to use a more aggressive correction. – Paolo Mar 15 '15 at 09:47
  • Why don't you want to stop the service? If you save this as a script it will update instantly. Also what do you get when you type `uname -a` – JeremiahBarrar Mar 15 '15 at 10:02
  • I know this method already. Thank you for your help though. So there's no way of having the fake clock to be more aggressive in its correction? The only way is to stop the service, make a hard sync with ntpdate and start the service again? The problem with this is that it's a very hard sync, not really recommended. I'd much rather like ntp to do its job less loosely. – Paolo Mar 15 '15 at 14:14
  • Well, ntp is designed to do that for a reason. If you want an instant update this is the way to do it. If this is your personal computer you should be fine. You can buy an external hardware clock, but it is a little complicated. Use the Google... – JeremiahBarrar Mar 15 '15 at 15:30
  • The reason hard-reseting the clock as show above can be bad is that it allows the OS clock to jump back in time, something that ntpd will never do (it will slow down the OS clock until real time catches up). – ndemou May 18 '16 at 07:29