Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Generally you can set system clock using However, it doesn't supply millisecond precision (it does have nanoseconds, but this isn't working on my system). Is there another way to set system clock, or will I need to write a C program to do it?

share|improve this question
up vote 2 down vote accepted

If ntpd is to heavy for you, try OpenNTPD. It doesn't claim to be sub-microsecond accurate, but does keep my servers' clocks in sync, below a milisecond's range of drift. It uses sntp, which is also a bit more lightweight.

As others have said, hardware clocks do drift, you can't just set them and be fine.

share|improve this answer

You should use ntpd which will keep your system accurate by syncing with time servers using NTP (Network Time Protocol).

share|improve this answer
Generally a good idea, but not in my case (an embedded system which can only talk to its own server). – Alexey Romanov Nov 15 '10 at 8:14
@Alexey Romanov Its own server can be NTP server for the device since same program can act as server and client. This way you could have a stratum 3 device which is very precise. – AndrejaKo Nov 15 '10 at 8:51

Even if the embedded system in question doesn't support NTP, you're going to have to implement something a lot like it, or execute your C program pretty frequently, in order to counter the inevitable drift of the two clocks. Plus, your C program will have to account for its own execution time and the latency of the connection between the two computers (embedded system and server), particularly as sub-microsecond precision is what you need.

It may be quicker for you to find a ntpd instance you can configure between the two systems. The tools for this are always present in modern real-time operating systems (for some definition of "always").

share|improve this answer
1. Sorry, millisecond (as in title), not microsecond. 2. Yes, I do take latency into account. – Alexey Romanov Nov 15 '10 at 8:39

You must log in to answer this question.

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