-
Notifications
You must be signed in to change notification settings - Fork 8
Run program at startup
Embedded systems typically start themselves up when they're powered on. For example, you don't have to type commands into your refridgerator, you just plug it in and it runs. Likewise with security cameras, etc.
Two of the ways useful for prototyping to have a program or service start automatically are by using cron or configuring a systemd service--consider one of the methods below.
Note: in general, I use the nano text editor on embedded systems. nano is installed by default in many modern Linux systems.
Systemd can start services at bootup. Users can define their own systemd services.
Note that Restart=no should be used for the simple example program. We generally don't have time in the miniproject to develop a daemon--but in your full semester project you might well use a daemon.
Another approach is to use cron.
Example crontab -e:
Note: you need to include any PATH that you might need. At the top I put
PATH=/usr/bin:/bin:/home/pi/.local/bin
and then at the bottom
@reboot python3 /home/pi/code/myprogram.py /home/pi/data