add systemd examples

This commit is contained in:
2026-02-06 20:27:19 -05:00
parent 041fbd0f5f
commit 8d250318b1

View File

@@ -0,0 +1,42 @@
# Systemd
## Timers
Basic timer:
my_service.timer
```conf
[Unit]
Description=Run $my_service every hour
[Timer]
OnCalendar=hourly
AccuracySec=10min
Persistent=true
Unit=$my_service.service
[Install]
WantedBy=timers.target
```
my_service.service
```conf
[Unit]
Description=Runs some command
After=syslog.target network.target auditd.service
Wants=network-online.target
[Service]
ExecStart=/usr/bin/command -with -arguments
[Install]
WantedBy=multi-user.target
```
Create an on-the-fly timer (will not survive reboots)
```bash
systemd-run --user --on-calendar '*:0/1' /bin/sh -c "date >> ~/log.txt"
```