Saturday, 4 August 2012

Shell Script for Disk Space


PATHS="/"

AWK=/bin/awk

DU="/bin/du -ks"

GREP=/bin/grep

DF="/bin/df -k"

TR=/bin/tr

SED=/bin/sed

CAT=/bin/cat

MAILFILE=/tmp/mailviews$$

MAILER=/bin/mailx

mailto="santosh@fecdirect.in"

for path in $PATHS

do

 DISK_AVAIL=`$DF $path |  $GREP -v "Filesystem" | $AWK '{print $5}'|$SED 's/%//g'`

 if [ $DISK_AVAIL -gt 60 ];then

  echo "Please clean up your stuff\n\n" > $MAILFILE

  $CAT $MAILFILE | $MAILER -s "Clean up stuff" $mailto

 fi

done

No comments:

Post a Comment

Twitter Bird Gadget