NetBSD-Users archive

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

(solved) Re: rc.local nightmare





On 10/30/23 08:25, Michael van Elst wrote:
ea1abz%gmail.com@localhost (Ramiro Aceves) writes:

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.


Your script shouldn't create output from a background process.
When booting, output is piped through a logging process, and when
that exits, the next output will abort your process.


Thanks so much Michael for the tips. It is working now redirecting stdout and stderr.

Now that it is working and I know the reason of what was happening, it is time to learn how to make a simple NetBSD service.

nohup doesn't help, it only redirects terminal output.

Ideally you should not print anything directly in a background
process but write a log file (or use logger / syslog).

To avoid any accidential problem, you should also redirect all
three standard handles (e.g. to /dev/null).

N.B. the connectivity check is a bit sensitive. I suggest to
probe with more than 1 packet and to also set a deadline (-w)
which allows for one extra second, e.g. ping -n -c 3 -w 4.

Thanks for that tip!

Ramiro




Home | Main Index | Thread Index | Old Index