ZFS scrub schedule on Ubuntu and Proxmox: the monthly cron job skips degraded pools
Debian-based distros, Proxmox VE included, scrub ZFS pools from /etc/cron.d on the second Sunday. We broke a mirror in a VM to see what that job reports, and how to get an alert when a scrub finds errors.
10 min read
Install ZFS on Debian, Ubuntu or Proxmox VE and you get a cron job with it. At 00:24 on the second Sunday of every month it scrubs your pools. It’s easy to never look at it. A scrub that finds damage will tell somebody, after all.
We built a two-disk mirror in a VM to see who that somebody is. Then we killed one of the disks, and the monthly job stopped scrubbing that pool completely. It still exits 0 every time.
ubuntu 26.04.1 · openzfs 2.4.1 · two-disk mirror · no mail command
- 300 MB corruptedscrub repaired 265M, job exited 0
- one disk deadpool DEGRADED, job skipped it, exit 0
- set to enablestill skipped, health is checked first
- zed email"mail" not installed, one journal line
- zpool scrub -wexit 0 after finding 161 data errors
- runwisp taskexit 1, push names the damaged file
Short answer
On Debian-based systems, Proxmox VE included, the zfsutils-linux package scrubs every ONLINE
pool at 00:24 on the second Sunday of the month, from /etc/cron.d/zfsutils-linux. The job only
starts the scrub and exits 0 within milliseconds. Results come hours later through ZED, the ZFS
event daemon, which by default emails root with a mail command that a minimal server doesn’t have.
A DEGRADED pool is skipped on purpose, and the job still reports success. If you want to hear
when a scrub finds damage, give ZED a way to reach you (an ntfy topic in zed.rc is one line), or
run the scrub yourself with zpool scrub -w and fail the job unless zpool status -x says the pool
is healthy. RunWisp, an open-source cron replacement that ships as a single binary, does the second
one and pushes the damaged file’s name to your phone, as tested below.
Where the schedule lives
$ cat /etc/cron.d/zfsutils-linux
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# TRIM the first Sunday of every month.
24 0 1-7 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/trim ]; then /usr/lib/zfs-linux/trim; fi
# Scrub the second Sunday of every month.
24 0 8-14 * * root if [ $(date +\%w) -eq 0 ] && [ -x /usr/lib/zfs-linux/scrub ]; then /usr/lib/zfs-linux/scrub; fi
| Release | OpenZFS | This cron file and scrub script |
|---|---|---|
| Ubuntu 26.04 | 2.4.1 | byte-for-byte the same |
| Debian 13 | 2.3.9 | byte-for-byte the same |
| Proxmox VE 9 | 2.4.4-pve1 | byte-for-byte the same |
OpenZFS also ships [email protected] for systemd, but none of these packages enables it.
systemctl list-timers --all on our fresh Ubuntu install didn’t list a single ZFS timer.
The scrub line runs every day from the 8th to the 14th, and the date +%w test bails out on the six
days that aren’t Sunday. It looks clumsy until you try the obvious 24 0 8-14 * 0. Cron ORs the
day-of-month and day-of-week fields when both are set, so that version scrubs on all seven days and
on every other Sunday of the month too.
Why the second Sunday? Because mdadm checks RAID arrays on the first one. Richard Laager, who proposed the job in Ubuntu bug 1548009 in 2016, didn’t want a box with both kinds of storage grinding through both checks on the same night.
The same bug also records the job’s first failure. Ubuntu 16.04 shipped it with cron’s default
PATH, which has no /sbin, and that’s where zpool lived. So every month the scrub couldn’t find
zpool and the error went to cron’s mail, until the fix reached 16.04 in August 2016. The PATH=
line at the top of the file is that fix.
How we tested
An Ubuntu 26.04.1 cloud image in QEMU with three 1 GB virtual disks, zfsutils-linux 2.4.1 from
the archive, and nothing else installed. The pool tank was a mirror of the first two disks with
600 MB of random data on it. We called /usr/lib/zfs-linux/scrub as root, which is all the cron
line does on the right Sunday, then corrupted the disks underneath ZFS with dd while the pool was
exported and ran it again. ZED, which zfsutils-linux pulls in, was running with its stock
zed.rc. The Debian and Proxmox packages we only diffed against Ubuntu’s, we didn’t boot them.
The job ends before the scrub starts
On a healthy pool the whole job took 26 ms:
# /usr/lib/zfs-linux/scrub; echo "exit=$?"
exit=0
# zpool status tank | grep scan
scan: scrub in progress since Mon Nov 30 17:34:58 2026
zpool scrub asks the kernel to start a scrub and returns. The scrub then runs in the background
for as long as reading the pool takes, which on a real array means hours. The script also wraps the
call in || true, so even a scrub that refuses to start doesn’t fail the job.
Then we overwrote 300 MB in the middle of the first disk with random data and ran the job again. Exit 0, just as fast. The scrub behind it found the damage and repaired it from the second disk, which is exactly what a mirror is for:
scan: scrub repaired 265M in 00:00:00 with 0 errors on Mon Nov 30 17:35:03 2026
config:
NAME STATE READ WRITE CKSUM
tank ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
virtio-disk1 ONLINE 0 0 2.08K
virtio-disk2 ONLINE 0 0 0
2,080 checksum errors on one disk is the most useful thing a scrub can tell you. That disk is
returning bad data, and when the other one fails there won’t be a good copy left to repair from.
The pool still says ONLINE, and the job had exited long before any of this was known. The only
thing left that could tell anyone is ZED.
Who ZED tells
ZED runs scrub_finish-notify.sh after each scrub, and when zpool status -x doesn’t call the pool
healthy, it sends a notice. Out of the box, zed.rc sets ZED_EMAIL_ADDR="root" and sends it with
mail. Our Ubuntu server image doesn’t have a mail command, so this is the whole notification:
# journalctl --no-pager | grep 'not installed'
Nov 30 17:35:03 zfslab zed[3256]: error: scrub_finish-notify.sh: eid=88: "mail" not installed
A stock Proxmox VE host does have Postfix, and root’s mail goes to the address you gave the installer. So there it works, as long as that’s an inbox you actually read. On a Debian or Ubuntu box set up from a minimal image, nothing is listening.
ZED can push to other places too. Put one of these in /etc/zfs/zed.d/zed.rc, then run
systemctl restart zfs-zed:
ZED_NTFY_TOPIC="zfs-7f3kq9" # plus ZED_NTFY_URL for your own server
ZED_GOTIFY_URL="https://gotify.example.com"
ZED_GOTIFY_APPTOKEN="..."
ZED_SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."
Pushover and Pushbullet are in there as well. Send yourself a test before you trust it, though. In the next test ZED didn’t say a word.
A dead disk ends the monthly scrub
We zeroed the second disk as if it had died, put 20 MB of fresh corruption on the first one, and imported the pool:
# zpool list -H -o health tank
DEGRADED
# time /usr/lib/zfs-linux/scrub; echo "exit=$?"
real 0m0.007s
exit=0
# zpool status tank | grep scan
scan: scrub repaired 265M in 00:00:00 with 0 errors on Mon Nov 30 17:35:03 2026
Seven milliseconds, exit 0, and the last scrub is still the old one. The reason is in the script:
# Scrub all healthy pools that are not already scrubbing as per their configs.
zpool list -H -o health,name 2>&1 | \
awk -F'\t' '$1 == "ONLINE" {print $2}' | \
while read pool
Only ONLINE pools make it through the awk. The script also reads a per-pool switch,
org.debian:periodic-scrub, and the package README says enable means “always scrub”. So we set
it to enable and ran the job again. Nothing. The health filter runs first, so enable never even
sees a degraded pool.
ZED was quiet too. A disk that’s already gone when the pool gets imported, which is what happens at
boot, gave us pool_import and config_sync events and no state change, so no notice. In real life
that’s a disk that dies across a reboot or a power cut.
Skipping the pool is deliberate, and the reasoning in the 2016 bug makes sense. Scrubbing a degraded pool adds load that could take out another disk, and a pool “should not be left degraded for very long” anyway, so the disk time is better spent on the resilver.
That holds as long as somebody actually replaces the disk. Here’s what a manual scrub of our degraded pool found:
# zpool scrub -w tank
# zpool status -v tank
scan: scrub repaired 0B in 00:00:00 with 161 errors on Mon Nov 30 17:35:42 2026
errors: Permanent errors have been detected in the following files:
/tank/data/blob
The second copy is gone, so the corruption on the surviving disk is permanent, and the scheduled job was never going to look for it. You find out when something reads that file, or when the resilver does. And if nobody notices the pool is degraded (easy, when nothing tells you), it can sit on one disk unscrubbed for months while the monthly job reports success.
Exit codes won’t help either
The obvious fix is to wait for the scrub and check the exit code. That doesn’t work. In the same
run, zpool scrub -w tank waited and exited 0 with 161 errors, and zpool status -x exited 0 on a
DEGRADED pool with permanent errors:
| Command, degraded pool with 161 errors | Exit | Says |
|---|---|---|
/usr/lib/zfs-linux/scrub |
0 | nothing, no scrub started |
zpool scrub -w tank |
0 | nothing |
zpool status -x |
0 | state: DEGRADED, 161 data errors |
zpool status -x on a healthy pool |
0 | all pools are healthy |
So OpenZFS’s own [email protected], which runs zpool scrub -w, would be green in systemctl
after this scrub as well. The text is the only thing you can rely on. ZED’s own notify script greps
for is healthy, and yours should too:
#!/bin/sh
# /usr/local/sbin/scrub-and-check: scrub one pool, fail unless it ends healthy
pool=${1:?pool}
zpool scrub -w "$pool" || zpool wait -t scrub "$pool"
zpool status -x "$pool" | grep -q "is healthy" && exit 0
zpool status -v "$pool"
exit 1
zpool scrub refuses to start while another scrub is running, and the || waits for that one
instead. The Debian job does respect the switch when it says disable, so set that to keep it from
scrubbing the same pool:
zfs set org.debian:periodic-scrub=disable tank
Under cron, an exit 1 still only goes to MAILTO, so this job needs the same treatment as any other
job you want to hear from. The cron alerts post has the options,
and where cron mail actually goes explains why it’s probably not
reaching you now.
A scrub that fails in RunWisp
RunWisp is an open-source cron replacement that ships as a single binary. We ran it as root on the same VM, with this task and an ntfy notifier:
[notifiers.phone]
type = "ntfy"
topic = "zfs-7f3kq9"
[tasks.zfs-scrub]
cron = "24 0 * * SUN#2"
timeout = "24h"
notify = ["phone"]
run = """
zpool scrub -w tank || zpool wait -t scrub tank
zpool status -v tank
zpool status -x tank | grep -q "is healthy"
"""
SUN#2 means the second Sunday, so there’s no date +%w trick. RunWisp listed the next run as
2026-12-13 00:24. The scrub runs inside the task, so the run takes as long as the scrub does, and
all of zpool status -v ends up in that run’s log.
On the degraded pool with the corrupted file, the run failed with exit 1 and this showed up on the phone:
❌ zfs-scrub failed
Exited with code 1 after 1s.
Triggered from the CLI · 30 Nov, 17:36.
errors: Permanent errors have been detected in the following files:
/tank/data/blob
With a faulted disk and no data errors the run failed too, and the push showed the one line that
mattered: virtio-disk2 FAULTED 0 0 0 external device fault. After we replaced the disk and
cleaned up, the next run passed and sent 💚 zfs-scrub recovered, so you also hear when it’s fixed.
If the box is off at 00:24 on the second Sunday, cron just skips that month. RunWisp runs the most
recent missed tick when it starts again (catch_up = 1 is the default). We stopped the daemon
across three ticks of a test task and it ran once on startup.
Every run also keeps its duration, and the run list sorts by it. A scrub that took 3 hours in spring and takes 7 now is a disk slowing down, and you can see it there long before it turns into checksum errors.
Install it with curl -fsSL https://get.runwisp.com | sh, put the task in
/etc/runwisp/runwisp.toml and run sudo runwisp service install. Then set
org.debian:periodic-scrub=disable on the pool, so the Debian job doesn’t scrub it a second time.
Common questions
When does Ubuntu scrub ZFS pools automatically?
Does the automatic ZFS scrub run on a degraded pool?
How do I get notified when a ZFS scrub finds errors?
Why does zpool scrub return immediately?
How do I turn off the automatic ZFS scrub for one pool on Debian or Ubuntu?
How do I schedule a ZFS scrub that alerts me when it finds errors?
Read next
-
Watchtower is archived: auto-update Docker Compose containers with a cron job instead
containrrr/watchtower was archived in December 2025, and 1.7.1 panics on Docker 29. A tested cron script that pulls and restarts your compose stacks, and the traps it avoids.
-
Cron in Docker runs in UTC: setting the container timezone with TZ and tzdata
TZ in a cron container did nothing on Ubuntu and Alpine images, which lack tzdata. On Debian the schedule moved while its jobs kept UTC. A fix that works on both.