I want to add a h/w rtc to my RPi. If network time is available, I want to determine this, and use it to set the system time and also update my own rtc. How can I find if network time is ( or becomes ) available ( preferably within a Python program)?

  • I just searched for "time" in the search bar on top and got several very good answers. Please use that next time...
    – Piotr Kula
    Commented Jun 10, 2013 at 16:01

1 Answer 1


DS1302/DS1307 are quite precise to be left alone without network sync for a long while, you may sync them manually right after the installation and forget about them.

however if you still insist to update your hw-clock from the network, I'd recommend to keep your NTP daemon running and create:

  • a small script running right after the boot, that reads hw-clock and sets the system time


  • a regularly running cron script, that will compare current system time and hw-clock time, if these differ substantially, the system clock must be reset by NTP daemon and you may want to copy the system clock to the nw-clock.
  • Thanks for the answer, but as a newcomer to Linux I don't know where to start with this. If I decide to keep with the external rtc, how do I set the system time, and how do I prevent the system time from being updated if the network is connected? Thanks
    – Neville
    Commented May 14, 2013 at 14:52
  • ntp daemon is responsible for network time updates, if you don't like it, you may disable it with sudo update-rc.d ntp disable
    – lenik
    Commented May 14, 2013 at 15:22
  • This has already been answered on this Q&A.
    – Piotr Kula
    Commented Jun 10, 2013 at 16:00

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