If you’ve ever run a Linux system in production or even just kept a personal server, you’ll know that running out of disk space is one of the most frustrating issues. Suddenly, your applications stop working, databases won’t write new data, and log files keep filling up like a runaway train.
The good news is that Linux makes it surprisingly easy to monitor disk usage and catch problems before they happen. All you need is a small shell script, a bit of logic, and maybe an email alert (or a message to your Slack channel, if you’re fancy).
In this article, we’ll build a simple script that checks your disk usage and sends an alert if it goes over 80%.