crontab entry with date command

crontab -l

*/1 * * * * sh /Davinder/Scripts/disk_wrap.sh

First script to just create log files: 
 
[root@linuxhost logs]# cat /Davinder/Scripts/disk_wrap.sh
#!/bin/bash
sh /Disk_full.sh >/Davinder/Scripts/logs/disk_full.log_`date +%d%m%^C%H%M%S`

Main script --> /Disk_full.sh  
#!/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
 

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