Script: Clean log file after "/" crossed 95% usage.

#!/bin/bash

DISK_USAGE=`df -TH | grep -w "/"|awk '{print $5+0}'`
#a=`echo ${DISK_USAGE%%.*}`
#echo "$DISK_USAGE"
a=${DISK_USAGE:0:2}
#echo $a
if [ $a -gt 95 ];
then
                echo "It is more than 96%..Cleaning Disk"
                echo 0 > /var/log/httpd/error_log
#               sleep 10
                Disk_Check=`df -TH | grep -w "/"|awk '{print $5+0}'`
                        if [ $a -gt 96 ];
                                then
                                        echo "Now disk usage of "/" partition is $Disk_Check"

                        fi

        else
                echo "Disk usage of "/" partition is $DISK_USAGE"%" and below the threshold"

fi

OUTPUT:
[root@linuxhost /]# ./Disk_full.sh
Disk usage of / partition is 74% and below the threshold


Comments

Popular posts from this blog

How to delete SEA in VIOS

Webmin configuration for LDAP

Sample questions and answers for AWS Associate Solutions Architect Certification ---> AWS exam dumps