From cdb12896283d48d9f1451bdea2295b448b801c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Daase?= Date: Sat, 30 Jan 2021 21:33:08 +0100 Subject: [PATCH 1/2] update example service and timer in manpage This does four things: - Set the "IOSchedulingClass" and "CPUSchedulingPolicy" to "idle" (we are a background task and should never block the system in any way) - Add "--quiet" to the exec line (at best, backups are fire and forget) - Mention our own man page in the "Documentation=" directive (good style) - Move the [Install] section to the bottom (convention) --- man8/snap-sync.8 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/man8/snap-sync.8 b/man8/snap-sync.8 index 4018891..87e3259 100644 --- a/man8/snap-sync.8 +++ b/man8/snap-sync.8 @@ -138,15 +138,18 @@ You can create systemd unit and timer. Here is an example service: .EX [Unit] - Description=Run snap-sync backup - - [Install] - WantedBy=multi-user.target + Description=Run snap-sync backup + Documentation=man:snap-sync(8) [Service] Type=simple - ExecStart=/usr/bin/snap-sync --UUID 7360922b-c916-4d9f-a670-67fe0b91143c --subvolid 5 --noconfirm - + ExecStart=/usr/bin/snap-sync --UUID 7360922b-c916-4d9f-a670-67fe0b91143c --subvolid 5 --noconfirm --quiet + IOSchedulingClass=idle + CPUSchedulingPolicy=idle + + [Install] + WantedBy=multi-user.target + .EE And here is its corresponding timer: @@ -155,6 +158,7 @@ And here is its corresponding timer: [Unit] Description=Run snap-sync weekly + Documentation=man:snap-sync(8) [Timer] OnCalendar=weekly From fc447392ecdebd86387c0b53c47b5592bb2196a4 Mon Sep 17 00:00:00 2001 From: Bao Trinh Date: Sun, 13 Feb 2022 19:58:59 -0600 Subject: [PATCH 2/2] replace CPUSchedulingPolicy from systemd service as suggested by wesbarnett this avoids the service from possibly being CPU-starved (see https://unix.stackexchange.com/questions/340283/using-and-understanding-systemd-scheduling-related-options-in-a-desktop-context) IOSchedulingClass, however, was kept. These options match `btrfs-scrub@.service` on Arch Linux --- man8/snap-sync.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man8/snap-sync.8 b/man8/snap-sync.8 index 87e3259..fe60f43 100644 --- a/man8/snap-sync.8 +++ b/man8/snap-sync.8 @@ -145,7 +145,7 @@ You can create systemd unit and timer. Here is an example service: Type=simple ExecStart=/usr/bin/snap-sync --UUID 7360922b-c916-4d9f-a670-67fe0b91143c --subvolid 5 --noconfirm --quiet IOSchedulingClass=idle - CPUSchedulingPolicy=idle + Nice=19 [Install] WantedBy=multi-user.target