Commit d340b1

2026-08-03 21:01:55 Niklas Polke: Additional SYSTEMD options
linux/systemd.md ..
@@ 30,12 30,19 @@
Environment=HOME=<home directory>
ExecStart=/usr/bin/flock --nonblock /tmp/<lock filename>.lock <script with absolute path>
ExecStop=
+
+ [Install]
+ WantedBy=multi-user.target|timers.target
```
- wants/after network-online.target mean that this service needs the network to be online
- Type `oneshot` is for short running tasks like backup scripts, `simple` for permanently running things like server and databases
- additional line `RemainAfterExit=yes` would be for things like `mount` which result is *active* even if the service has exited - then also an additional lne for `ExecStop` would be necessary to `unmount` the service
+ - Environment could also be directory of python (inside a virtual environment)
- flock create lock file to prevent different backups running in parallel
- nonblock means, that additional starts doesn't wait but stop executing
+ - `Restart=on-failure` means restart if service crashed
+ - `RestartSec=5` delay for automatic restart
+ - `Install WantedBy` tells the service what to do when `systemctl enable` is called
2. Test service
```bash
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9