Daemonizing in rc.local

I am using HomePlugAV devices that have power-saving mode on as default but the problem is when they go to sleep they stay asleep. Nothing turns them back on without pulling them out the socket and pushing them back in again. There is nothing in the manual about turning off this feature. So I am using PING to broadcast packets on the 255 address every 2 minutes to keep them awake. I have a number of routers one being a Lenovo Newifi D1 on 21.02.0 and a Mi4C running 21.02.1.

Lenovo Newifi D2
syslog: daemon.notice procd: /etc/rc.d/S95done: PING ( 56 data bytes
processes: 2417 root ping -i 120

syslog: daemon.notice procd: /etc/rc.d/S95done: PING ( 56 data bytes
daemon.notice procd: /etc/rc.d/S95done: ping: sendto: Network unreachable

With the Mi4C there is no background process

Any ideas why the Mi4C is unable to background the ping process?

I don't think that there should be any difference in daemonising between the OpenWrt versions that you are using.

But I suspect that you are mis-using the rc.local and not really daemonising.

I suggest that you run the ping command from a detached shell, so that the RC.local (s95done) can otherwise finish and exit.

See e.g.

On the other hand, a process that runs every two minutes does not need to be demonized, you can run it from cron.

Or you can use the "ping" module on "luci-statistics", and have a nice graph with the response times.

finally solved the issue after some real hair pulling. In rc.local I inserted a line at the top "sleep 30". My guess is this Mi4C containing the 7628 being a slower CPU than the twin core 7621 in the D1 causes a race condition on boot. Inserting sleep 30 as the first line in rc.local allowed PING to daemonize on boot. I think adding sleep 30 as the first line in rc.local might be the first config I add to all my routers from today onwards.

.# Put your custom commands here that should be executed once
.# the system init finished. By default this file does nothing.

#papdee: just sleep a while so system can complete startup scripts
sleep 30

#papdee: prevent powerline adapters going into sleep mode
ping -i 120 &

exit 0

I installed luci-statistics. Will use it to gain insight to my routers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.