Rc.local does not execute shell command

I want to execute a shell script at the startup of the router.

my rc.local

#!/bin/sh -e

/etc/init.d/test.sh &

exit 0

and the test.sh file

#Check WAN Connection

echo "running test.sh" > /tmp/test.txt
exit 0

But I don't have any file in the /tmp/ folder

Adding a a similar echo "running rc.local" > /tmp/rclocal.txt line to the rc.local generates the file successfully, so this means rc.local is executed, but my script is not.

How can I solve this?

Change to: ./etc/init.d/test.sh &

Also ensure that you chmod +x /etc/init.d/test.sh to make it executable.

Alright, I tried what is mentioned above. Still nothing. I made sure both rc.local and test.sh are executable..but the file is not there!

I don't have this in my rc.local file. If adding a period doesn't work, I'd try removing that instead.

Sorry to tell you that, but still nothing :frowning:

echo "logger -t rc-local test-log" > /etc/rc.local
/etc/init.d/done enable
/etc/init.d/done boot
logread -e rc-local

Generally, backgrounding without daemonizing in an init script is problematic.

1 Like

It finally worked...Seems the Notepad++ ASCII bytes are different than that of the internal editor or WINSCP...

Everything is tight. Thanks for all the help!

1 Like

Doing something like this, too, rather often, and having had bad experience with it recently, can you explain, why it is problematic ?

Parent process and file descriptors vanish

1 Like

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