0

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)?

BobT
  • 794
  • 4
  • 6
Neville
  • 1
  • 1
  • I just searched for "time" in the search bar on top and got several very good answers. Please use that next time... – Piotr Kula Jun 10 '13 at 16:01

1 Answers1

0

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

and

  • 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.
lenik
  • 11,503
  • 1
  • 29
  • 37
  • 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 May 14 '13 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 May 14 '13 at 15:22
  • This has already been answered on this Q&A. – Piotr Kula Jun 10 '13 at 16:00