Having discovered that systemd can even be used as a replacement for Cron, I'm migrating most of my maintenance scripts to systemd Timers.
Here's how to have your BTRFS volumes scrubbed using parameterized units:
#/etc/systemd/system/btrfs-scrub@.service [Unit] Description=Scrub BTRFS filesystem (%i) [Service] Type=simple EnvironmentFile=/etc/conf.d/btrfs-scrub-%i ExecStart=/usr/bin/btrfs scrub start -B $mountpoint
#/etc/systemd/system/btrfs-scrub@.timer [Unit] Description=Trigger BTRFS scrub on filesystem (%i) [Timer] OnCalendar=monthly Persistent=true [Install] WantedBy=timers.target
In order to have a volume (e.g. your home partition) scrubbed you simply activate the timer...
$ systemctl enable firstname.lastname@example.org
... and specify the mount point in the corresponding configuration file,
in this case
The configuration file seems a bit superfluous here, but AFAIK there's
no way to supply filesystem paths via
Note that these units do not include any form of notification in case of a scrubbing fail! I personally don't need this as my logs are monitored using journalcheck.
Update 2015-07-12: Changed unit type to 'simple' to make it compatible with long-running machines.