Hi! I need to monitor multiple files and filter lines that contain a word
One approach is to use pipe. The command tail with its output coupled with the grep command for each file monitored. Each pipe would write in a single file as background processes Then use another tail monitoring the single file that is the union of the other files filtered. Here is my code. [code] rm -f /tmp/tailLogfile #File log list for v in `ls /var/scp/log/*child*.log` do echo Monitoring $v tail -100f $v | egrep -e "MessageIN" >>/tmp/tailLogfile 2>&1 & done echo Monitoring "/tmp/tailLogfile" tail -100f /tmp/tailLogfile [/code] When running, the last tail is my monitor. To exit should press Ctrl + C. My problem is that I can not kill the tail and grep processes that run in the background once it finishes the script. And the worst thing is that is generated new instances every time I run the script. If i use $! to capture the last pid of background process on the line [code] tail -100f $v | egrep -e "MessageIN" >>/tmp/tailLogfile 2>&1 & [/code] $! capture only grep pid but not tail pid to kill them Anyone know of any way to solve this? -- This message posted from opensolaris.org