I'm executing the set of commands in remote machine via ssh command. But the control is not even going inside the if statement (not echo-ing anything).
/usr/bin/ssh ${2}@${1} <<EOF >/var/tmp/housekeeping_${1}_${2}_`date +%Y%m%d%H%M%S`.log
if [ `df -h . |cut -d'%' -f1 |tail -1|awk '{print $NF}'` -eq 100 ]; then
echo -e "File system is 100% full, hence removing the below files..."
find . -name "*.log.gz" -mtime +10
#find . -name "*.log.gz" -mtime +10 -exec rm -f {} \;
echo -e "File system is 100% full, hence compressing the below files..."
find . -name "*.log" -mtime +7
#find . -name "*.log" -mtime +7 -exec gzip {} \;
if [ `df -h . |cut -d'%' -f1 |tail -1|awk '{print $NF}'` -eq 100 ]; then
echo -e "File system is 100% full, hence removing the below files..."
find . -name "*.log.gz" -mtime +5
#find . -name "*.log.gz" -mtime +5 -exec rm -f {} \;
echo -e "File system is 100% full, hence compressing the below files..."
find . -name "*.log" -mtime +3
#find . -name "*.log" -mtime +3 -exec gzip {} \;
fi
fi
EOF
i get the below message when i execute the script,
gives the desired result, however if I use that code inside a if condition (listed below) it is not working properly.
if [ `df -h . |tail -1 |cut -d'%' -f1 |awk '{print \$NF}'` -ge 85 ]; then
echo -e "File system is above 85% full, hence removing the below files..."
find . -name "*.log.gz" -mtime +10
#find . -name "*.log.gz" -mtime +10 -exec rm -f {} \;
echo -e "File system is 100% full, hence compressing the below files..."
find . -name "*.log" -mtime +7
#find . -name "*.log" -mtime +7 -exec gzip {} \;
As the above if statement didn't work,control is not coming inside the if condition. When i tried to use the below variable in if statement, it also fails. when i do echo of $fs_usage, it displays nothing.