Show all running services
systemctl list-units --type=service
Creation of a failsafe service
[Unit]
Description=My App
StartLimitIntervalSec=30
StartLimitBurst=2
[Service]
ExecStart=/usr/local/sbin/my-app.sh
Restart=on-failure
The StartLimitBurst=2 and StartLimitIntervalSec=30 settings tell systemd that if the service unsuccessfully tries to restart itself twice within 30 seconds, it should enter a failed state and no longer try to restart.
hard iron in Service:
Restart=always
RestartSec=10 (or more seconds)
Delay a service:
[Service]
ExecStartPre=/bin/sleep 30
Build a timer that runs a script
/etc/systemd/system/foo.timer
[Unit]
Description=Daily autoboot
[Timer]
OnCalendar=*-*-* 06:30:00
Persistent=true
[Install]
WantedBy=timers.target
/etc/systemd/system/foo.service
[Unit]
Description="Reboot device"
[Service]
Type=simple
ExecStart=/usr/bin/systemctl --force reboot
Update changes
systemctl daemon-reload