My disk hit 100% on a Thursday night. Just a silent crash and a bunch of errors I found the next day.
I had nothing running in the background watching for problems.
**
- Disk space warning** The script I needed before that Thursday happened.
`#!/bin/bash
THRESHOLD=80
USAGE=$(df / | awk 'NR==2{print $5}' | tr -d '%')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
echo "⚠ Disk at ${USAGE}% — time to act"
else
echo "✓ Disk OK: ${USAGE}% used"
fi`
I just happened to be doing some brushing up on crontab a bit lately so I automated the script before I did anything else, so this wouldn't happen again.
Full script with email alerts → bashsnippets.xyz/snippets/disk-space-warning.html
2. Killing Processes
I also found myself continuing to fall into a ps aux | grep ""
loop after cleaning up the disk and new there was a one-word command out there that made it easier, but I couldn't recall...
I had to google it a few times before it stuck with me:
pkill/pgrep <--- turned a 4 command work-flow into a one-word workflow:
My loop was this:
ps aux | grep myapp # find it
kill 12345 # copy/paste PID
ps aux | grep myapp # confirm it died
After, it was this:
pgrep -l myapp
pkill -x myapp
Where this went:
So, of course, these and a few more, like error handling, turned into a free, and growing script library at bashsnippets.xyz — copy-paste ready, explained line by line, no signup.
I also started turning each one into a short video on YouTube (@bashsnippets). Hoping to gain some traction in the beginner bash communities!
Hope someone can find some use of this, but What are you automating? Drop it in the comments.










