English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to monitor a log file for a while and was going to have inittab run tail -f logfile | grep ERROR | xargs -n1 -i mailit.sh {}

Where mailit.sh is just a 2 line program:
echo $1 > error.log
mail -s "Error occured" my@email.com < error.log

or any other suggestions for realtime monitoring of a log file.
Its VERY BUSY always getting written too.

Thanks,

2007-08-09 13:05:16 · 1 answers · asked by Bart 2 in Computers & Internet Programming & Design

1 answers

"tail -f" does a "follow" operation -- it keeps the file open, checks for appending to the file, and never exits -- so I'm not sure this would work.

For what it's worth, we use "tail" on log files that grow by megabytes per minute, without issues. I think that "tail" is fairly easy on system resources (it probably checks to see if the file is longer, with stat() and then gets the bytes).

2007-08-09 13:18:30 · answer #1 · answered by McFate 7 · 0 0

fedest.com, questions and answers