|
Try like this!! Not sure if it is efficient.
while read -p err_line
do
echo $err_line | grep "pattern" && echo "mailx scripts goes here"
done
For the change of timestamp in the logfile, you could check for the time in this loop and exit it after 00:00 and then start the loop again. See if this works for you.
You can catch the pid of the background job and kill it before you reassign the logfile name,But make sure you have lot of error check into the script. I did it below like this.
while true #the main loop
do
tail -f $logfile |&
while read -p line
do
job_id=$! #get the background job process id
echo $line | grep "pattern" && echo "mailx scripts go here"
if [[ `date +%H` -lt 1 -a `date +%M` -gt 5 ]]; then #check for your time
break; #break out from loop
fi done
kill $job_id #kill the id
sleep 5 # wait for sometime for the kill to complete its action.
logfile="$LOG/May_19.log" #reassign logfile
done
Last edited by ranj@chn; 05-19-2006 at 02:08 AM..
|