Here is a simple script that will check if your specified partition is almost full and will notify you if it is. In order to have an email send, you must have mailx installed, for installation check my post here.
- change user@mail.com with your email
- change /dev/sda1 with the partition you want to monitor
- change threshold value with the desired one.
eg. If you want to get notifications if your specified partition is more than 90% full, enter 90
#!/bin/bash #start editing mail="user@mail.com" partition="/dev/sda1" threshold="90" #stop editing percent=$(df -h | grep "$partition" | awk '{ print $5 }' | sed 's/%//g') if ((percent > threshold)) then echo "$partition at $(hostname -f) is nearly full" | mail -s "Your disk is nearly full!!!" "$mail" fi
You can place it in crontab and have it executed automatically
eg. to check once every day, insert into cron
23 6 * * * /path/to/script
it works. thanks.
Thanks bro
Thanks for your script 🙂 it work’s on Fedora.
Awesome, works in ubuntu 14.04
df -h /
will only give you the disk usage results for the root partition, perhaps usedf -h
You’re absolutely right.
Fixed.
Thank you