Getting a startup script to start?
-
Hey all, I'm trying to get a script started at boot. It doesn't start when added to crontab ("@reboot /usr/local/bin/start-script") at the bottom, nor does it by adding it to /etc/rc.local. It only starts if I start it manually and then it runs fine.
Is there some sort of trick to getting scripts to run on a Raspberry Pi with RetroPie at boot?
Note: I'm actually testing this on a Debian VM with Emulation Station.
-
rc.local should work are you putting & at the end so it goes in the background?
i run a few things in rc.local works on wheezy and jessie without issue
full path is also important when using rc.local
in the file for example and if it's a bash script make sure it's got #!/bin/sh at the beginning of the file
#!/bin/sh
/usr/local/bin/start-script &Those are just a few things I can think of off the top of my head
-
Thanks for the reply. Here's my rc.local -
/usr/local/bin/start-video-screensaver &
exit 0It's a Python script. Should I try putting this as the first line instead of #!/bin/sh?
#!/usr/bin/env python2 -
rc.local is a shell script so no you want #!/bin/sh in it
in your python script though you should start it with the python line if it doesn't have it already
or prefix the script with python /path/to/script
-
@DJQuad I'm not sure if this will work but you may try just putting sudo at the start of each line you want to run. If is doesn't work it can just be deleted.:-)
-
This is how I got my python restart script to work.
- Save script to /home/pi
- Edit the /etc/rc.local file and add the following line ABOVE 'Exit 0'
- python /home/pi/restart.py &
-
Unfortunately no go. Can any of you please try it on an actual Pi preferably with RetroPie installed? The script is actually on GitHub at https://github.com/windweaver828/Video-Screensaver and the readme is at https://github.com/windweaver828/Video-Screensaver/blob/master/README.md
xautolock should be listed as a process if it's running and I also set the start time in the cfg to 1 minute.
-
@DJQuad That wont work with RetroPie. It is designed to be run under a desktop on X (it uses some X tools, but could be modified I guess to work without them).
-
Even though Omxplayer is used to play the videos?
-
Yes. It uses xautolock
http://linux.die.net/man/1/xautolock
The code would need changing to remove this dependency and use another method to trigger etc.
-
Right but like I said, it runs just fine and as expected if it's started manually after a restart.
Perhaps turning it into a service would be better since it needs to be run as root?
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.