1

Is it possible to use ntpd to log all time resets and adjustments rather than set system clock?

user626528
  • 220
  • 2
  • 3
  • 12

1 Answers1

0

From a look at the ntpd man page this doesn't look possible. It does save out stats of what it is receiving but it will always try to set the time. You could in theory hack out those system calls but that sounds dangerous/over the top.

If you just want to get what the time differences were, you could look at running ntpdate with the query switch -q. Try it and see whether it is spitting out the right info for your purposes. From the manpage:

-q Query only - don't set the clock.

Or there is the debug switch -d which may print out more info that you need.

webtoe
  • 1,976
  • 11
  • 12
  • It seems this can work, but it will provide less accuracy than running ntpd continuously. – user626528 Apr 12 '12 at 09:48
  • I think you're only other options would be to hack `ntpd` to pieces to remove the sections of code that change the time. i.e. comment out the time setting call and recompile the code. This would be messy. What exactly are you trying to achieve that requires not setting the time? We may be able to suggest a better solution. – webtoe Apr 12 '12 at 09:55
  • I need to have precise time in my program, but I can't change system time as program doesn't have such rights. The system doesn't have ntpd installed, because this is Windows. – user626528 Apr 12 '12 at 09:58
  • Right, well you asked about `ntpd` in your question and didn't say that you were running windows. I suggest you update your question. Your program doesn't need to have the permissions. The Windows Time Service (or `ntpd` on linux) can keep your system's clock accurate. Then in your program, just query the system time. This is how you solve this problem. – webtoe Apr 12 '12 at 10:15
  • Windows Time Service is not any accurate. It has error of +- several seconds, what is completely not acceptable. – user626528 Apr 12 '12 at 10:26
  • Then try something in this list (which is referenced by the MSDN article that states why w32time is deliberately inaccurate): http://www.nist.gov/pml/div688/grp40/softwarelist.cfm – webtoe Apr 12 '12 at 10:45
  • run `ntp` with `-d` option. It will log a truck load of messages to the journal, but there will also be a message indicating that the clock was adjusted. – ilya1725 Jul 30 '18 at 20:32