This guide explains how to automatically start a program running on a Raspberry Pi or other Linux computer. This will feature systemd, desktop autostart files and cron.
There are already dozens or even hundreds of programs or daemons that run a computer. These could be keeping the time on your computer correct, handling print requests, receiving networking requests, handling the graphical interface or even starting other programs to run at scheduled times. If you enjoy physical computing maker projects (in which case you may want to look at my list of maker projects), then it's quite common to want them to start automatically so that they can start running a program without needing user interaction, or so that they start a program that a user may interact with.
If you enjoy physical computing maker projects, then it's quite common to want them to start automatically. This may be so that they can start running a program without needing user interaction, or so that they start a program ready for a user may interact with.
This guide will be based around systemd, desktop files with autostart, and crontab. The examples are based around the Raspberry Pi OS, but most other Linux distributions work with these methods.
There are other ways of getting programs to run automatically, but these are ones that are generally well supported and based around the modern approach. With these techniques then you should be able to start any kind of program you need.
Examples include: Running server daemons, RGB Matrix display, starting the chromium web browser in kiosk mode, Interactive badges controlled by a joypad (qjoypad) and turning Christmas lights on and off using Pi Power with Energenie.
Below are some useful links:
Guide to systemd startup and desktop autostart
http://www.penguintutor.com/raspberry...
Raspberry Pi RGB matrix
http://www.penguintutor.com/projects/...
Guide to scheduling programs using cron, crontab and at
http://www.penguintutor.com/linux/cro...
Snowman project
http://www.penguintutor.com/projects/...
Guide to setting up qjoypad
http://www.penguintutor.com/news/rasp...
Raspberry Pi robots
http://www.penguintutor.com/projects/...
Xmas light project / Pi power
http://www.penguintutor.com/linux/xma...
http://www.penguintutor.com/raspberry...
Chapters:
00:00 Introduction to Linux Startup Processes
01:16 Running maker projects at startup
02:02 Startup techniques covered
03:35 Starting server daemon programs with systemd
12:37 Starting the Chromium browser in kiosk mode (desktop autostart)
22:20 Starting a pygame zero game and qjoypad with desktop autostart
28:01 Running a program at a scheduled time with cron
33:07 Summary