I would like to automate zpool scrubbing on my ZFS server. I have written the following systemd service as /etc/systemd/system/zfs-scrub.service
)
[Unit]
Description=Scrub ZFS tank pool
[Service]
Type=simple
ExecStart=/bin/sh -c 'zpool scrub `zpool list -H -o name`'
RemainAfterExit=yes
ExecStop=/bin/sh -c 'zpool scrub -s `zpool list -H -o name`'
As well as a timer (as /etc/system.d/system/zfs-scrub.timer
) :
[Unit]
Description=Run zpool scrub every 1st Saturday
[Timer]
OnCalendar=Sat *-*-* 22:00:00
After having started it a few weeks back, I checked to see if it behaved. It seems that systemd still thinks the service is running, so the timer didn't run.
It seems there is no ExecStatus
, so systemd doesn't know that the service completed.
- Am I missing something ? Should I instead write a script that starts the scrub, greps the zpool status line and catch signals to stop the scrub when systemd signals it ?
- Is it possible to write a
OnCalendar
line that means "once per month, only on weekends" ?
simple
overoneshot
because zpool scrub won't stay around (it just triggers the scrubbing and exits). The thing is that there's no text reporting when you trigger scrub (maybe exit codes, but I haven't checked), apart from grepping zpool status from time to time to get status/progress, and I didn't want to write a wrapper. – Flighty