I have an OpenFrameworks-based app on my Raspberry Pi that I want to autorun as soon as the Pi is powered. Currently, we have to (1) connect the Pi to a monitor via HDMI, (2) manually login via a keyboard and then (3) navigate through the folders to run the app. Is there any way to bypass these three steps and run the app directly after power-on?
Thanks in advance for your help!
There are lots of strategies. If this one doesn’t work, google will give you lots of raspberry pi specific ideas.
@hahakid wrote this a while back
I’m using crontab, which uses the cron shell that starts on startup and does the things you ask it. there is a lot of documentation for cron on Linux/OSX systems, and you can do a lot with it. The crontab file is what tells cron what to do. here is how you can modify it to run your oF app:
sudo crontab -e
then go to the bottom of that file and add your script of commands. i did this:
@reboot sleep 10 && cd /home/pi/openFrameworks/apps/myApps/<yourAppFile>/bin && ./<yourAppName>
@reboot tells cron to run this stuff when the system starts up.
sleep 10 tells it to wait 10 seconds (this is give enough time for other modules, etc. to load, as cron is not the last thing to load. after that, the script jumps into the
/bin directory and runs your application.
The main problem with method is that it is running through the cron shell, not your normal user shell. As a result, the only way to quit is if you ssh in from another machine and
kill -9 the application ID.