NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: rc.local nightmare





On 10/29/23 23:59, Brad Spencer wrote:
Ramiro Aceves <ea1abz%gmail.com@localhost> writes:

Hi all,


[snip]

The script works fine if I run manually:

#/root/nettest


or even If I do this it works fine:

#service local restart

But If I reboot the machine the script starts during booting but I dies
very soon.

I do not understand what is happening here. I know that the proper way
is writing a rc.d service but I am just curious to know the reason.

Thanks so much.
Regards.

Ramiro.




The NIC on the RPI can take a while to actually come available depending
on what it is connected to.  This seems to be especially true if dhcp is
being used.  What may be happening is that the network isn't available
yet when rc.local runs and your scripts thinks it can't get anywhere.  I
noticed this because /etc/rc.d/ntpdate wasn't setting the date and time
because the device couldn't get anywhere (yet).  I dealt with this by
adding some sleep to /etc/rc.d/ntpdate to slow the boot down a bit and
allow the NIC and network to settle.  You may want to do something
simular.... another method to consider is to keep some more state around
for your script and only allow it to do the reboot check if it had
succeeded in getting out on the network once.


Hello Brad. Thanks for the tip. I do not use DHCP, I use static address. I think that network is working fine before rc.local starts to run.

My script says on the console "Network connectivity to $TARGET is OK." several times before the script dies. So ping works fine. (I have set INTERVAL=3 seconds just to speed things up during testing.

Thanks so much.

Ramiro.








Home | Main Index | Thread Index | Old Index