42 lines
612 B
Markdown
42 lines
612 B
Markdown
# 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"
|
|
``` |