My Script . This check log file size every 1 minute.
#! /bin/bash
logFiles="log1.log log2.log"
logLocation="/usr/home/test/log/"
sleepTime=60
failMessage=":: Log not running :: Pls Check Service"
successMessage="OK"
arr=($logFiles)
arrlen=${#arr[@]}
arrcount=()
date
for ((count=0; count<arrlen; count++)) ; do
arrcount[$count]=`ls -l $logLocation${arr[$count]} |awk '{print $5}'`
echo "${arr[$count]} Original size :: ${arrcount[$count]}"
done
echo
while [ "e" == "e" ] ; do
sleep $sleepTime
date
for ((count=0; count<arrlen; count++)) ; do
nc=`ls -l $logLocation${arr[$count]} |awk '{print $5}'`
echo -n "${arr[$count]} "
if [ $nc == ${arrcount[$count]} ] ; then
echo $failMessage
else
arrcount[$count]=$nc
echo $successMessage
fi
done
echo
done
Ex. out put my script.
Fri Mar 11 02:09:28 ICT 2011
log1.log Original size :: 262311887
log2.log Original size :: 236930257
Fri Mar 11 02:10:28 ICT 2011
log1.log OK
log2.log OK
Ex. If. log2.log not update
Fri Mar 11 02:12:28 ICT 2011
log1.log OK
log2.log :: Log not running :: Pls Check Service
I want out put.
If. log2.log not update
Fri Mar 11 02:14:28 ICT 2011
log1.log OK
log2.log not update file size.
Fri Mar 11 02:15:28 ICT 2011
log1.log OK
log2.log not update file size 1 minute.
Fri Mar 11 02:16:28 ICT 2011
log1.log OK
log2.log not update file size 2 minute.
Fri Mar 11 02:17:28 ICT 2011
log1.log OK
log2.log not update file size 3 minute.
.
.
.
.
.
.
Fri Mar 11 02:37:28 ICT 2011
log1.log OK
log2.log not update file size 33 minute.
Please help to write this script.
Regards