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)?
1 Answer
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.
-
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– NevilleCommented 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
– lenikCommented May 14, 2013 at 15:22 -