Catch a filling disk weeks before it becomes an outage

Catch a filling disk weeks before it becomes an outage

●2 ●38 ●102
calendar_today • schedule1 min read

A disk almost never fails loudly. It fills a percent at a time until writes stop, and at 100% nothing reports "disk full" — the database throws write errors about its own files, apps crash-loop, and logging (a write itself) stops recording at the exact moment you need evidence. You end up debugging five fake problems instead of one real one.

The prevention costs one line on a daily cron:

df -h | awk 'NR>1 && $5+0 >= 80 {print $0}'

NR>1 skips the header. $5+0 is the trick: df's Use% column is a string like 82%, and awk's numeric coercion keeps the leading digits and drops the %, so the threshold comparison works without cut or sed. Pipe any output to mail -s and you get an email the day a filesystem crosses 80.

Why 80? At 80% a disk growing one percent a day leaves you weeks to investigate with du -ah | sort -rh | head -20. At 95% you're deleting files under pressure; at 100% every service on the box misbehaves at once.

This check is #1 in a set of 25 cron-ready bash scripts for sysadmins covering disk monitoring, backups, service watchdogs, SSL expiry, and port audits.


I bundled the scripts I copy onto every new server, plus 10 bonus ones, into the Production Bash Toolkit. 30-day refund if it isn't useful.

Want more #devops & #linux deep dives?

Join 6,093+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

A deploy guard that passes with no token

BashSnippets - Nov 24

FluidCloud's CEO on Why NSX Firewall Rules, Not Disk Copies, Stall VMware Exits

Tom Smithverified - Nov 17

Every disk-alert script I had piped into a command this machine does not have

BashSnippets - Oct 15

bash ran a path that no longer existed, and exited 127

BashSnippets - Oct 21

My 30-day log cleanup kept a file that was 30 and a half days old

BashSnippets - Oct 8
chevron_left
3.8k Points • 142 Badges
North America • bashsnippets.xyz
79Posts
38Comments
14Connections
Linux user who got tired of Googling the same bash commands every time I sat down at a terminal. Sta... Show more

Commenters (This Week)

1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!