Guys, > I have to write a script that online monitors a > log file to check if a particular error message > turns up there. > The log file is quite big and I need to run some > commands right after the message appears in the log. > So, to grep for the message in every 1 second won't > work, because at the time the script finished > to grep the huge file some valuable seconds > would elapse. Many thanks to everyone for your invaluable help!!! The world would be a harsh place without you guys! ==================================================== You can look at swatch and/or logcheck (or is it checklog). swatch is more for continual monitoring (taking more immediate action), logcheck more for periodic. logcheck tracks where it left off in the file and seeks to that point before continuing, so it may have the performance requirements you need. ==================================================== logsurfer, logcheker, etc. ==================================================== tail -f logfile | grep pattern | while read line; do echo found it: $line #do other stuff done Run that as a daemon process. -f ==================================================== logbot logsurfer swatch syslog-ng jabber and whatnot on freshmeat.net or sunfreeware.com. They all have this similar functionality. ==================================================== #!/bin/ksh tail -f logfile | while read LINE; do if echo $LINE | grep 'HELLO' >/dev/null; then I=$(($I + 1)) echo "Encountered $I HELLOs" fi done ==================================================== #!/bin/sh tail -f /yourlog|grep yourmsg|while read line; do echo execute commd using $line done ==================================================== http://sourceforge.net/projects/simple-evcorr/ http://www2.logwatch.org:81/ There are others... ==================================================== If you're thinking of perl, the File::Tail module can help you out here. If not, you can still do something like tail -f <filename> | grep "mystring" in you script, but you'll have to watch out for logfile rotation etc. Regards, John __________________________________ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more. http://info.mail.yahoo.com/mail_250 _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagersReceived on Thu Jan 27 17:46:55 2005
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:42 EST