The problem lies in the way tail -f works. The mail command never gets an EOF that would trigger it to send the mail. Your script isn't going to work this way. Try something along the lines of: for i in `tail -f alert_M.log | grep log`; do mail -s foo root@localhost<<_EOF found $i in logfile . _EOF done Also, make sure your /etc/mail.rc file doesn't containt set askcc -- otherwise mail will sit there waiting for you to enter the CC address (which you can't since mail isn't attached to a tty) :) Cheers Stefan On Tue, Jul 8, 2008 at 10:57 PM, Shivaswamy / ಶಿವಸ್ವಾಮಿ < shivaswamykr@xxxxxxxxx> wrote: > Hello. > > I am attempting to look for a pattern in the continuously growing log file > and mail me if match is found. (on Linux). But I am having problem. > This is the part of the shell script > export err1=down > tail -f testlogfile | egrep -n "${err1}" | mail -s "Found warning" > shivaswamykr@xxxxxxxxx > As you see I am using tail -f and egrep. When I run only tail -f & egrep > part on the prompt on my testlogfile, I am able to see the output from > egrep. > But when I pipe it to mail, and run it on nohup on a shell script, nothing > happens. I can see that mail process is in T state, meaning it is stopped. > If I kill my shell script running in the background, I get the email > notification, as expected. > What happens here? How I can get the notification, without killing the > process? > If you could please help, I appreciate it. > Thanks, > Shiva > -- ========================= Stefan P Knecht Senior Consultant Infrastructure Managed Services Trivadis AG Europa-Strasse 5 CH-8152 Glattbrugg Phone +41-44-808 70 20 Fax +41-808 70 12 Mobile +41-79-571 36 27 stefan.knecht@xxxxxxxxxxxx http://www.trivadis.com OCP 9i/10g SCSA SCNA =========================