RTC in raspberry pi.

Rama Tito
Rama Tito used Ask the Experts™
Hi Experts,

i do have two raspberry pi, One as publisher and another one as a subscriber. It works on the local area network without internet. Data transmission and receiving, works fine and data storing into MariaDB also works fine. The issue is time. The router run locally without internet connection. If someone switch off or restart router, the system depend on router time which not synchronise online time.

To over this issue, i did add in RTC DC3231 in both raspberry with the following setup.

# Reset the System Clock to UTC if the hardware clock from which it
# was copied by the kernel was in localtime.


#if [ -e /run/systemd/system ] ; then
# exit 0

if [ -e /run/udev/hwclock-set ]; then
    exit 0

if [ -f /etc/default/rcS ] ; then
    . /etc/default/rcS

# These defaults are user-overridable in /etc/default/hwclock
if [ -f /etc/default/hwclock ] ; then
    . /etc/default/hwclock

if [ yes = "$BADYEAR" ] ; then
    /sbin/hwclock --rtc=$dev --systz --badyear
    /sbin/hwclock --rtc=$dev --hctosys --badyear
    /sbin/hwclock --rtc=$dev --systz
    /sbin/hwclock --rtc=$dev --hctosys

# Note 'touch' may not be available in initramfs
> /run/udev/hwclock-set

Open in new window

After i did this , its work on RTC time till someone reset or switch off the router. Upon router up, the raspberry pi picked up router time instead of RTC time. i have to do manually to switch to RTC time.

How i can over this, by saying just depend on RTC time only.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

Is there an ntp service active?   The please halt that.
( ps ax | grep ntp )
Rama TitoProgrammer


run on putty
In the attach picture i do get the result after typing "ps ax |grep ntp".
May i know what i am trying to acheive.
Software Engineer
Distinguished Expert 2018
The right commands would have been: sudo service ntpd stop or sudo systemctl stop ntpd
ntpd is a (Network Time Protocol) daemon to get the times right, it can respond to multicast, or query specific servers.
Your description seemed to indicate response to multicast.  THe NTP daemon can also be used to use other time sources like GPS, DCF77, etc. etc.
There might be other tools doing more or less the same job as well.

you can check ps ax (process list output) for any process that might have anything to do with time

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial