Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Generally you can set system clock using http://linux.die.net/man/1/date. 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
add comment

3 Answers

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
add comment

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
1  
@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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.