Skip to content

Instantly share code, notes, and snippets.

@tribut
Created September 15, 2015 21:45
Show Gist options
  • Save tribut/5103c2fd3195b6444b2f to your computer and use it in GitHub Desktop.
Save tribut/5103c2fd3195b6444b2f to your computer and use it in GitHub Desktop.
Btrfs scrub cronjob with logs from systemd's journalctl
#!/bin/sh
# also see http://marc.merlins.org/perso/btrfs/post_2014-03-19_Btrfs-Tips_-Btrfs-Scrub-and-Btrfs-Filesystem-Repair.html
for fs in $(grep ' btrfs ' /proc/mounts | cut -d' ' -f1 | sort -u)
do
starttime="$(date "+%Y-%m-%d %H:%M:%S")"
logger "Starting btrfs scrub on $fs"
btrfs scrub start -Bd "$fs"
journalctl -q -k --since "$starttime" | grep BTRFS
logger "Scrub for $fs has finished"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment