Inicial > Linux > Disk Space script for Linux

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
Categorias:Linux Tags:, , , ,
  1. Ferretti
    junho 22, 2017 às 7:44 pm

    You need replace “9[1-9])” to “([1-9])”.
    You need remove “100)”.

    • junho 23, 2017 às 11:40 am

      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%

  1. No trackbacks yet.

Deixe um comentário