Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is Ubuntu (3.13.0-29-generic #53), trying to do a simple bash script to monitor a log file for matching lines.

If I do the following, there is no output in the bash shell except for matches, which is expected:

tail -F server.log | grep --line-buffered "word" | tee -a wordwatch.log

But if I try to do the same thing in a screen, the session is spammed with unmatched data from the watched log file. Apparently it's showing everything from the watched log file. This spam does not appear in the output log file.

screen -S "wordwatch" tail -F server.log | grep --line-buffered "word" | tee -a wordwatch.log

What am I doing wrong and how do I stop the watched log from spamming the screen session?

share|improve this question
up vote 10 down vote accepted

When you launch the pipe such way:

screen -S "wordwatch" tail -F server.log | grep --line-buffered "word" | tee -a wordwatch.log

then only tail -F server.log is launched within screen and all the rest is connected to the screen, not the tail.

Therefore you should invoke your bash script that works already:

screen -S "wordwatch"

The other approach is to launch the shell explicitly and pass all the line to it:

screen -S "wordwatch" bash -c 'tail -F server.log | grep --line-buffered "word" | tee -a wordwatch.log'

Also the other good way to watch logs with screen - is the special config:

#### logger.screenrc
sessionname     logger
hardstatus alwaysignore
screen  -t "Log One"  1 sh -c 'tail -F /a/b/c | egrep "xxxx" | tee -a '
screen  -t "Log Two"  2 /home/
screen  -t "Messages" 3 /home/

screen should be invoked like that:

# screen -c /home/logger.screenrc

To exit just press <CTRL-A><CTRL-\> and confirm.

share|improve this answer
Thank you, I'd vote you up, but I need more rep here. – Dale Mahalko Aug 31 '14 at 15:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.