How to monitor disk space and avoid running out
Updated 7/20/2026
When the disk fills up, databases stop, logs stop writing and the site can go down. Prevention is simple.
1. Check space
df -h
2. Find what uses space
du -sh /var/* | sort -h
du -sh /home/* | sort -h
Frequent culprits: uncleaned logs, old backups, unused Docker images (see Docker cleanup).
3. Automatic alert at 85%
A simple script that runs in cron and warns you:
#!/bin/bash
USED=$(df / | awk 'NR==2 {print $5}' | tr -d '%')
if [ "$USED" -gt 85 ]; then
echo "Disk at $USED% on $(hostname)" | mail -s "Disk alert" [email protected]
fi
0 * * * * /usr/local/bin/check-disk.sh
4. Free up space
- Configure log rotation, see logrotate.
- Move backups to a Backup Box.
- If it is still too little, move to a plan with a bigger disk.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Monitoring & logging
How to monitor database performance
See slow queries, connections and database usage, to keep it fast.
Updated 7/20/2026Monitoring & loggingHow to configure log rotation with logrotate
Logs grow forever and fill the disk. logrotate archives and deletes old ones automatically.
Updated 7/20/2026Monitoring & loggingHow to monitor a website and SSL expiry
Do not let your site go down or your SSL certificate expire without knowing. Here is how to track them automatically.
Updated 7/20/2026