amadeus84
Posts: 18
Joined: Sun Jun 22, 2014 5:55 pm

can't run script at boot

Sat Apr 11, 2015 11:56 pm

At boot I need to run a script that uses gpio to read input from a motion sensor in an infinite loop, so I put

/home/pi/myscript &

in /etc/rc.local, before the exit 0 line. The script does not start though. Any help troubleshooting this?How do I even check that /etc/rc.local is being run? I tried putting echo commands in /etc/rc.local before myscript, but I can't find anything when I grep for the message in /var/log/messages.

Needless to say, the script runs flawlessly when started at the prompt (via ssh from another computer).

This would be for a demo due this coming Monday, so a timely answer would be highly appreciated.

Thanks!

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: can't run script at boot

Sun Apr 12, 2015 8:20 am

What kind of script is it? Bash, python or anything else?

To check if rc.local is running you can redirect echo output to a file:

Code: Select all

echo "rc.local is running" > /home/pi/message.log

amadeus84
Posts: 18
Joined: Sun Jun 22, 2014 5:55 pm

Re: can't run script at boot

Sun Apr 12, 2015 2:35 pm

Thanks for the answer! Following your suggestion to echo to a file from rc.local does show that it runs.

My script is a shell script. It uses gpio to read an input pin (from a motion sensor), then if the pin is high, it plays an audio message using espeak and raises an output pin (again with gpio) to turn on a light.

This is done in an infinite loop, but I do spawn my script with an & when I start it from rc.local.

I wonder if this is somehow related to the explanation I've found here:

http://askubuntu.com/questions/239600/w ... o-about-it

I need to investigate that. Possibly something in my script fails, for whatever reason, at the time it is being called from rc.local.
Maybe run my script with

#!/bin/bash -x

??

amadeus84
Posts: 18
Joined: Sun Jun 22, 2014 5:55 pm

Re: can't run script at boot

Sun Apr 12, 2015 5:51 pm

Problem solved!

My script uses gpio, which is in /usr/local/bin, which is not in the path at the time when /etc/rc.local is being run at boot. Adding /usr/local/bin to the path in my script solved the problem.

Return to “Troubleshooting”