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
#!/bin/sh
#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?
Yamadron:
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!
Yamadron:
#!/bin/sh -e
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
echo "logger -t rc-local test-log" > /etc/rc.local
/etc/init.d/done enable
/etc/init.d/done boot
logread -e rc-local
jeff
September 27, 2019, 9:23pm
7
Yamadron:
/etc/init.d/test.sh &
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
jeff:
/etc/init.d/test.sh &
Doing something like this, too, rather often, and having had bad experience with it recently, can you explain, why it is problematic ?
jeff
September 28, 2019, 10:22am
10
Parent process and file descriptors vanish
1 Like
system
Closed
October 8, 2019, 10:22am
11
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.