Disk Space script for Linux
Sometimes I need to keep checking the disk space at my servers. So, I created the following script and add it to Crontab. If I have problems, Ill receive an email.
This can be useful to someone!
#!/bin/bash # In my case im interested in a specific partition /opt/XYZ SPACE=`df -h | grep /opt/XYZ | awk '{print $4}' | awk -F % '{print $1}'` case $SPACE in 9[1-9]) echo "Disk space > 90 %, please check" | mail -s "Disk Space problem" email1@br.ibm.com,email2@br.ibm.com;; 100) echo "Disk Full, please check" | mail -s "DISK FULL" email1@br.ibm.com,email2@br.ibm.com;; esac
You need replace “9[1-9])” to “([1-9])”.
You need remove “100)”.
Hi, tks for your input. But for my case, I want to receive an email if Disk space are > 91% and < 100%. And another message if Disk space is 100%