Skip to content
This repository was archived by the owner on May 27, 2020. It is now read-only.

Run program at startup

Michael Hirsch, Ph.D edited this page Sep 18, 2019 · 5 revisions

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

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.

Cron

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

Clone this wiki locally