Is there a reliable way to sync clock of a totally offline linux server, which is only occasionally connected to a client?

I imagine passing a single "millis-since-epoch" number to the server may not be precise, even though is simple.

Wondering if it is possible to "feed" NTPD (running on server) with necessary information obtained by the client from NTP server.

  • I think you have to define "client" in this case. The typical use of ntpd is as a client running on your linux server. When there is internet connectivity, the ntpd, running on your server, connects as a client to some ntp server across the internet. As such, there is no occasional connection from your linux server to the client because they are on the same host.
    – nmgeek
    Commented Dec 15, 2020 at 18:17

2 Answers 2


The important thing to note is that the on-machine clock isn't necessary trustworthy; it can drift, and different machines drift at different rates. ntp tries to measure that drift, but it needs enough connected time to work out an approximation.

The standard way of keeping clock sync for machines that can't (for some reason) sync to NTP servers on the internet is to have a local 'authoritative' time source. Typically that's a GPS receiver. Now your machine has access to an accurate time source.

Without an external time source there's nothing on your machine that can be considered sufficiently trustworthy.

Now if you're not totally concerned about accuracy and just want to 'resync' on connection then running ntpdate when the link is established may be sufficient. You should be aware that this may cause the clock to go backwards so this isn't recommended (Unix time is meant to monotomicaly increase), but it may not harm your use case.

  • @nmgeek if you have a different problem (e.g. "how do I use ntpdate") then please ask a new question. Your error message is because you're using the command wrong. Commented Dec 11, 2020 at 0:52
  • You can also configure ntpd to use the onboard clock when no internet connection is present but use an internet-based ntp server when an internet connection is present. See serverfault.com/questions/806274/…
    – nmgeek
    Commented Dec 15, 2020 at 18:25

Using GPS is indeed the simplest way to synchronize system clocks. My internet connection is typically good, but this is Frontier and there are about a few days of outage per year. Since I synchronize my IP security camera clocks from the Internet, and these camera have really bad internal clocks, I needed something more stable. So I went for GPS.

I tried configuring ntpd and gpsd together, but all the steps described on the Internet assume that you are using a PPS signal, which requires both a more expensive GPS and kernel patches. I was interested in neither, not wanting to maintain my Linux kernel by hand forever.

On the other side, I knew a bit about NTP and GPS, and I was interested to learn more. A NTP server is actually very simple (the client does most of the work). I have worked with GPS and NMEA in the past. I bough a cheap USB GPS mouse (about $12). It took me a few weeks of on-and-off work, but I now have a NTP server with quasi no configuration needed, easy to install on a Raspberry Pi or Debian PC: HouseClock.

In addition I dislike the existing NTP server tools: I embedded a web console using my own echttp web server library.

Overall, I spent more time than figuring out how to setup gpsd, but I do have the ability to monitor it (and other equipment) automatically from a web client.. which is my future pet project. In addition, I got some issues with time synchronization with my IP cameras, and being able to monitor the NTP client activity has helped me figure it out (a camera firmware bug on leap years).

All advises are that without PPS GPS synchronization is not very stable beyond 1 second. My experience is that it is mostly stable, but may get off by 50 to 100 ms for some time. Who cares: I am not doing particle physic experiments. A 1 second accuracy is good enough.

Since I had another Raspberry Pi not very loaded, I bough a 2nd GPS mouse and, voila, a redundant pair of home-made NTP servers..

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .