RTC in raspberry pi.

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.

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

dev=$1

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

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

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

# These defaults are user-overridable in /etc/default/hwclock
BADYEAR=no
HWCLOCKACCESS=yes
HWCLOCKPARS=
HCTOSYS_DEVICE=rtc0
if [ -f /etc/default/hwclock ] ; then
    . /etc/default/hwclock
fi

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

# 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.
Rama TitoProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nociSoftware EngineerCommented:
Is there an ntp service active?   The please halt that.
( ps ax | grep ntp )
Rama TitoProgrammerAuthor Commented:
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.
nociSoftware EngineerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.