From a2d4a65466791b597ad75461efe4637587a468a8 Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Sun, 1 Sep 2024 20:16:09 +0200 Subject: [PATCH] doc: add systemd timer and service example --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 1c879b2..f64716e 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,42 @@ Recommended crontab usage: (do not forget logrotate) +### Systemd + +Recommended systemd usage: + +```toml +# /etc/systemd/system/dc-ops.service +[Unit] +Description=Run dc-ops once +After=docker.target + +[Service] +Type=simple +WorkingDirectory=/opt/dc-ops/ +ExecStart=python3 dc-ops +``` + +```toml +# /etc/systemd/system/dc-ops.timer +[Unit] +Description=Start dc-ops service periodically + +[Timer] +Persistent=true +OnCalendar=*:0/15 +Unit=dc-ops.service + +[Install] +WantedBy=timers.target +``` + +Enable and start the timer: +``` +systemctl enable dc-ops.timer +systemctl start dc-ops.timer +``` + ## Parameters See `dc-ops --help`