Managing ZFS scrub via systemd
<p>I would like to automate zpool scrubbing on my ZFS server. I have written the following systemd service as <code>/etc/systemd/system/zfs-scrub.service</code>)</p>

<pre><code>[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`'
</code></pre>

<p>As well as a timer (as <code>/etc/system.d/system/zfs-scrub.timer</code>) :</p>

<pre><code>[Unit]
Description=Run zpool scrub every 1st Saturday

[Timer]
OnCalendar=Sat *-*-* 22:00:00
</code></pre>

<p>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.</p>

<p>It seems there is no <code>ExecStatus</code>, so systemd doesn't know that the service completed.</p>

<ul>
<li>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 ?</li>
<li>Is it possible to write a <code>OnCalendar</code> line that means "once per month, only on weekends" ?</li>
</ul>