1833877 Members
1840 Online
110063 Solutions
New Discussion

Re: monitor a log file

 
Sachin_46
New Member

monitor a log file

hey,
i have a log file which gets updated every minute. I need to create a script which monitors the log file , if it doesnt update for 5 minutes then send me an email.
I can put this cron and run every 5 min.
Is there any way i can write a script or use a find command?
The log file time stamp is in GMT!
thanks,
2 REPLIES 2
Muthukumar_5
Honored Contributor

Re: monitor a log file

You can try this as,

#!/bin/sh
cd
touch newfile
find . -type f -newerm newfile
rm -f newfile

Put this file in cron to execute for every 5 minutes.

hth.

Easy to suggest when don't know about the problem!
Joel Girot
Trusted Contributor

Re: monitor a log file

Hi Sachin
maybe something like that ?

#!/usr/bin/ksh
while true
do
touch /tmp/timefile
sleep 300
if test /tmp/timefile -nt /tmp/yourlogfile ; then
echo "timefile newer than yourlogfile" | mail root
else
echo "yourlogfile acceded since five minutes"
fi
done

Joel