Archlinux auf dem Raspberry Pi
Programm automatisch starten
Soll das Programm auch dann wieder gestartet werden, wenn es durch einen Fehler
oder welche Ursache auch immer beendet wurde, muss in der Datei <program>.service
die Zeile "Restart=always" vorhanden sein (s.u.).
- Datei <program>.service in /usr/lib/systemd/system ablegen :
# nano /usr/lib/systemd/system/<program>.service
#################################################################
#
# <program>.service
# systemd service: start <program> at start
#
#################################################################
[Unit]
Description=Start <program>
[Service]
# Type=oneshot : starts the program once, that's it
# Type=simple : default, necessary when using "Restart"
Type=simple
ExecStart=/home/<user>/<program>/<program> /home/<user>/<program>/<program>.conf
# Restart=always : starts the program at once if it was finished in any way !!!
Restart=always
[Install]
WantedBy=multi-user.target
# EOF
- Sicherheit einstellen :
# chmod 644 /usr/lib/systemd/system/<program>.service
# ls -l /usr/lib/systemd/system/<program>.service
-rw-r--r-- 1 root root 351 30. Apr 19:56 /usr/lib/systemd/system/<program>.service
- Service aktivieren :
# systemctl enable <program>.service
Created symlink /etc/systemd/system/multi-user.target.wants/<program>.service
→ /usr/lib/systemd/system/<program>.service.
- Service starten :
# systemctl start <program>.service
Eine gute Beschreibung, wie man ein Programm mittels Timer startet, findet sich auf
Systemd/Timers – wiki.archlinux.de
© Uwe Jantzen 10.08.19