OK, an example from my real life of a computer with intermittent internet connection.bob wrote:OK, HOW does the time deviation reach 1000s? Only by human interference. Which means nothing will work if a human is in the middle of the process. How else does the clock get off that far?abulmo wrote:Not everybody is running a cluster of servers. On tablets, laptops, etc., with intermittent network connections, ntpd is not working as you except. If the time deviation is big enough (1000s), ntpd is not going to correct anything, and you have to change the time manually. For smaller time deviation, ntpd can call settimeofday and produce big time jump if you are using the obsolescent settimeofday function. This is only for small time deviation that ntpd works as you describe it. On a permanently connected computer, only small deviations may occur, but in real life, not all computer are permanently connected.bob wrote:
By far, a properly configured ntpd is the most commonly used and least problematic time fix that doesn't wreck things.
And for the record, ANYONE running with root access is absolutely a security risk. I don't think you can find a single person on the planet that has not broken something while running as root. Which is why most of us with any experience do not use root as our working account.
(1) shutdown and a later reboot? an ntpdate during boot solves that, before ntpd decides to give up and quit. That's automatic on boot up.
(2) a suspend/wake on a laptop (closing the lid)? The wakeup will correct the clock if things are set up correctly. Again, no problem.
Are you going to do EITHER of those while playing a chess game where a monotonic clock is important? If you WANT to break anything, you can. But if you let ntpd run, and leave it alone, you get exactly the effect most want. Which is an accurate clock across all machines you are using so that Make does not get confused, a monotonic clock so that you don't have to deal with negative intervals, etc.
When I travel, I bring my laptop to places without wifi connection nor ethernet plugs, but I can connect it from time to time to the internet through my 4G mobile phone. Usually I let my computer working all days, doing some timed computations, and I will only connect it to the internet when I am present. If my computer stays a few days, or even weeks without internet connection it's internal clock can be off time by a few seconds. Once connected to internet, my computer real time clock can then be abruptly set to the network time, going forward or backward.
I wonder what is wrong with using clock_gettime. It 's a POSIX standard. It solves a potentially existing problem.