A full disk rarely announces itself politely. One morning your site loads fine, and by the afternoon WordPress cannot save a post, MySQL refuses new writes, and uploads fail with a vague error. Setting up disk space alerts on VPS servers takes about half an hour, and it turns that surprise into a warning while you still have time to act. This guide covers manual checks, sensible thresholds, and three alert methods: a cron script with email, Telegram notifications, and a monitoring dashboard.
Why Disk Space Alerts on VPS Save Your Site
On a VPS, a full root partition does more damage than a full uploads folder. Databases need free space for temporary tables and binary logs. When that space hits zero, MySQL can stop accepting writes, and visitors who try to log in, comment, or check out see errors. Backups fail too, at the moment you most want a fresh one. That is why monitoring VPS disk space before it fills up and crashes MySQL matters more than checking it once a month by hand. An alert at 80 percent gives you days to clean up or resize. An alert at 100 percent gives you an outage.
Logs, Docker images, old backups, and WordPress uploads are the usual suspects. A runaway log file can add gigabytes in a day if a plugin starts writing errors in a loop. Alerts do not fix that, but they tell you about it before your visitors do.
Check Your Disk the Manual Way First
Before you automate anything, look at the current state so your thresholds mean something. Run df -h and note the Use% column for the root partition, usually /. Then run df -i to check inodes: a disk can run out of inodes while still showing free space, and writes fail with nothing obvious to explain why.
Next, find what is actually using the space. du -sh /var/* 2>/dev/null | sort -rh | head -10 shows the ten largest directories under /var, where logs, databases, and web files usually live. If you run Docker, check it separately with docker system df. Our walkthrough of monitoring disk, RAM, and CPU usage on a VPS with htop and Glances pairs well with the alert setup below.
Note two numbers before you continue: the current Use% and the size of the largest directory. If you are already above 80 percent, fix that first. Alerts on a disk that is already nearly full will only tell you what you already know.
Pick Alert Thresholds That Give You Time
Two thresholds work better than one: a warning at 80 percent and a critical alert at 90 percent. The warning is your cue to clean up during normal working hours. The critical alert means free space now, because the next few percent can disappear fast if a backup or a log spike starts.
On a small disk, percentages hide the real margin. Eighty percent of a 20 GB disk leaves 4 GB; ninety percent leaves 2 GB, and a single backup can eat that. If your disk is 20 GB or smaller, warn at 75 percent and treat 85 percent as critical.
Method 1: A Cron Script That Emails You
This is the simplest setup that works, and it needs nothing beyond tools already on most Ubuntu servers. Create a script at /usr/local/bin/disk-alert.sh:
#!/bin/bash
THRESHOLD=80
USAGE=$(df / | awk 'NR==2 {print $5}' | tr -d '%')
HOST=$(hostname)
if [ "$USAGE" -ge "$THRESHOLD" ]; then
echo "Disk usage on $HOST is at ${USAGE}%. Check it now." | mail -s "Disk warning: $HOST at ${USAGE}%" [email protected]
fi
Make it executable with chmod +x /usr/local/bin/disk-alert.sh, then add this cron job with crontab -e:
*/15 * * * * /usr/local/bin/disk-alert.sh
That checks every 15 minutes and emails only when usage is at or above the threshold. Two details decide whether this works. First, test the mail path: temporarily lower the threshold below current usage and confirm the email arrives. A mail setup that silently fails is worse than no alert. Second, prevent repeat spam: the script emails every 15 minutes while the disk stays above the threshold, so add a state file with a timestamp so it alerts only once per day at warning level, or once per hour at critical level.
For vps disk monitoring with email, keep the message short: hostname, partition, current percentage, and the largest directory. When an alert wakes you at night, that detail saves a login just to learn which server and disk is involved.
Method 2: Telegram Alerts With a Bot
Email gets buried. Telegram messages get read. If you already use Telegram, a bot alert is the faster channel, and it takes only a few extra lines in the same script. Create a bot with BotFather, note the token, and send the bot one message so you can get your chat ID from the Telegram API. Then replace the mail line with this curl call:
curl -s -X POST "https://api.telegram.org/botYOUR_TOKEN/sendMessage"
-d chat_id="YOUR_CHAT_ID"
-d text="Disk warning: $HOST is at ${USAGE}% full."
Keep the token in a separate config file, not pasted into a script other users can read. Run chmod 600 on it and source it from the script. If the token ever leaks, revoke it in BotFather and generate a new one.
Telegram also suits the critical threshold well: send the warning by email and the critical alert by Telegram, so the urgent one lands on your phone. Test both paths by lowering the threshold temporarily and confirming the message arrives. A vps disk usage alert that you never tested is a guess, not a safeguard.
Method 3: A Dashboard With Netdata or Uptime Kuma
Scripts suit one server. If you run several, or you want graphs alongside alerts, a monitoring tool fits better. Netdata installs in minutes, shows disk use per partition in real time, and can send alerts by email or Telegram once you set its thresholds. Its trend line also answers the question a single percentage cannot: how fast is the disk filling, and when will it hit 90 percent?
Uptime Kuma takes a different angle. It watches uptime and can check disk use through a push monitor, with Telegram, Discord, and email notifications set up from its web interface. If you already run it for uptime checks, adding disk alerts there keeps everything in one place. Our guide to setting up Netdata on Ubuntu 24.04 for real-time server monitoring covers the install and the first alert rules.
Whichever tool you pick, set the same thresholds: warning at 80 percent, critical at 90 percent, adjusted down for small disks. Keep the free disk space linux check as a habit too: a weekly glance at the trend graph catches slow growth, like a backup folder gaining a gigabyte a month, long before any threshold fires.
What to Do When an Alert Fires
An alert is only useful if you know the next three moves. First, confirm the number with df -h and find the growth with the du commands from earlier. Second, free space safely: rotate or delete old logs, prune unused Docker images with docker image prune -a after checking nothing running needs them, and remove old backups only after confirming a newer copy exists elsewhere. Our guide to setting up log rotation on your VPS before logs fill the disk shows how to stop logs growing without bound. Third, fix the cause: a log growing a gigabyte a day points at an error worth fixing, and a backup folder that never gets pruned needs a retention rule.
Do not delete database files, live uploads, or anything under /var/lib/mysql by hand to make room. That trades a full disk for corrupted data. If the disk is genuinely too small, resize it. For Docker-heavy servers, cleaning up old Docker images to free disk space on your VPS is often the fastest safe win, because unused images can hold several gigabytes nothing on the server still needs.
Keep Alerts Useful, Not Noisy
Alerts fail in two ways: they never fire, or they fire so often you stop reading them. Test each channel once a month by lowering the threshold for a few minutes, confirming the message arrives, and putting it back. Review the thresholds after any big change, such as adding a site or starting daily backups. Write the cleanup steps down somewhere you can reach from your phone, because the alert that arrives while you are away from your desk is the one that matters most.
Set the warning at 80 percent, the critical alert at 90 percent, pick email or Telegram, and test it today. A full disk is one of the few outages you can see coming days in advance.