January 17th, 2014, 09:19 AM
Compensating for clock drift on RedHat server
I have two RedHat servers on an isolated network with a bunch of client terminals. I have NTP set up so that they all keep the same time, but unfortunately without a local time source or access to the internet, I'm having to use the server's internal clock as the authoritative time source, and runs a few seconds per day slow. I'd like to avoid buying a GPS clock, although I'd be willing to consider that option if what I'm asking really can't be done.
Is there some way to configure the NTP service to adjust for the server's clock drift, while still using it as the time source? I'd like the clock to be within a few minutes of the actual time, so I've been occasionally adjusting it to compensate for the drift. I know that GPS units can do this, but the clock doesn't really need to be that accurate. Since the drift seems pretty constant it seems like there ought to be some way to do it in software.
January 17th, 2014, 10:28 AM
This may sound a stupid question but, without an external time source (such as an authoriative ntp server) how is your server supposed to know it's own time has drifted?
If you are willing to risk it, and this is a crap suggestion, and the drift seems constant you could (I am not even sure I am suggesting this!) have a cron job that every period of time (maybe every day or every Sunday) at a quiet time (perhaps 1am?) does a date command to set the clock to a revised value. To save having to calculate what time to set it to, you could have the cron job scheduled to run x minutes from 'the hour', where x is the number of minutes drift, and have the command set the time to the hour.
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
January 17th, 2014, 02:15 PM
No, that's the "correct" answer. There's really no way for it to know. However, I tracked its clock manually for a while and the drift seemed pretty consistent.
Originally Posted by SimonJM
February 4th, 2014, 11:44 AM
Ok, I dug into this a little further and I found that I can adjust the system date forward 5 seconds (or whatever amount corrects the time drift) like this:
date -s "$(date -d "5sec")"
For now, I am going to try adding that to cron.daily and see if it corrects the clock drift.