/etc/rc.local calling another script

Hello all

I am running a script at start up from /etc/rc.local that is supposed to call another script that resides at a /home directory that I created and I can see rc.local runs because I log to a text file but the script that it calls does not execute.

I changed the attributes of the sub-script
by executing

chmod a+x /etc/rc.local

and

chmod a+x runpython.sh

but it does not execute.

Do I have to set up something else?

Any help is greatly appreciated!

Here is the code inside /etc/rc.local

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

wifi-live-or-reset
boot-complete-notify

# Uncomment the following line in order to reset the microntroller
# right after linux becomes ready

#reset-mcu

# Uncomment the following line in order to disable kernel console
# debug messages, thus having a silent and clean serial communication
# with the microcontroller

echo 0 > /proc/sys/kernel/printk
echo Starting runpython>/tmp/showtrol.log
cd /home
runpython.sh
exit 0

and here is the code inside runpython.sh:

echo Running Python server...
echo Starting script kronos.py at >>/tmp/showtrol.log
date>>/tmp/showtrol.log

cd /home
python sc.py

But If I check the showtrol.log file only the text written by the rc.local script is there and not the one written by runpython.sh

THANK YOU

Rod Magnus

You should have a shebang at the beginning of the runpython.sh script to let the system know what interpreter should process the file. You have the extension .sh which tells you that it's a shell script, but the system doesn't care about the file extension.

So, be sure to start runpython.sh with:

#!/bin/ash

Also, Linux will not look in the current directory for an executable file. The file must either be on the system search path, or you must reference it explicitly. The most common way to do that is to use '.' for the current directory, using this format: ./runpython.sh

However, since you are setting the current directory in rc.local, and then in runpython.sh, it would be more efficient to just reference /home/runpython.sh directly. Not changing the directory in rc.local will have less side effects if you go and make later changes to the script.

So, try ending rc.local with:

echo Starting runpython>/tmp/showtrol.log
/home/runpython.sh
exit 0

Awesome!

It worked perfect

I had no idea about the shebang.

The funny thing is that on previous projects I did the same and it worked without the shebang but not now.

Maybe they were interpreted by default

THANK YOU so much

Have a great weekend

Sincerely
Rod Magnus