The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 05-26-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,802

Code:
while true
do
      tail  -f file.log | grep -q 'ERROR'
      if [ $? -eq 0 ] ; then
            cat file.log | /usr/bin/mailx -s 'logfile error' me@whereIam.com
            break
      fi
done

NOTE: this is a lame example because the loop never ends on a file that doesn't have errors. I have no idea what will tell you (using another similar grep check for success)
when to exit the loop.