Launching a python script on a RPI on startup (aka creating a standalone RNBO/Python box)
Since this issue was discussed on Discord I wanted to share my solution to launching a Python script on startup to integrate with a RNBO patch, or to simply add a standalone power button.
- ssh into RPi
- Create Launcher Script
- nano launcher.sh
-- #!/bin/sh
-- # launcher.sh
-- cd /
-- cd home/pi
-- sudo python scriptname.py
- Make it executable
- chmod 755 launcher.sh
- Test if script launches Python code
- sh launcher.sh
- Create logs directory
- mkdir logs
- Add launcher to crontab
- sudo crontab -e
-- @reboot sh /home/pi/launcher.sh >/home/pi/logs/cronlog 2>&1
- Test functionality
- reboot
- if script doesn’t run: cat cronlog