A service sample file
This Config file is a basic example on how to execute a script during a boot time and auto-restart program on systemd Linux
$ cd /etc/systemd/system$ touch foo.serviceDescription : Your app simple description.
ExecStart : Your app or shell script path.
Restart : Restart options
| Restart settings/Exit causes | always | on-success | on-failure | on-abnormal | on-abort | on-watchdog |
|---|---|---|---|---|---|---|
| Clean exit code or signal | * | * | ||||
| Unclean exit code | * | * | ||||
| Unclean signal | * | * | * | * | ||
| Timeout | * | * | * | |||
| Watchdog | * | * | * | * |
RestartSec: Time to sleep before restarting a service.
StartLimitIntervalSec StartLimitBurst reference
- If your app needs to display GUI window, you need to add
Environment.
Environment="DISPLAY=:0"
You need to find your XAUTHORITY path.
Just type echo $XAUTHORITY to check.
Environment="XAUTHORITY=/yourPath/Xauthority"
$ sudo chmod 755 foo.service$ sudo systemctl daemon-reload$ sudo systemctl enable foo.service$ sudo systemctl start foo.service$ sudo systemctl status foo.servicenetwork-online.target: is a target that actively waits until the nework is "up", where the definition of "up" is defined by the network management software. more