I have a putty session tailing a log. I either keep flipping to it to see in anything has come up or I forget to check it at all. Can putty or tail be made to "beep" if anything scrolls into the window?


will this work?:

tail -f /var/log/messages  | sed 's/^/\a/'
  • This is so close! It works as it is, but I'd like to filter out some routine messages that come up so I pipe to grep -v first. Full thing looks like "tail -f server.log | grep -v "Invalid chunk ignored." | sed 's/^/\a/'" and it looks like it's buffering before piping to sed. Hmmmm....it just did beep but it looks like it buffered a bunch of messages. Maybe took a couple minutes. That might be "good enough", though I'll watch it to see if it's consistent enough. – eflat Dec 20 '10 at 20:50
  • It seems to be buffering 22-23 lines before it sends output to window and beeps. That behavior ring a bell (no pun!) for anyone? – eflat Dec 20 '10 at 21:36
  • Thanks to another answered question on SO, I found that this works: tail -f server.log | while read line ; do echo "$line" | grep -v "Invalid chunk ignored." | sed 's/^/\a/'; done – eflat Dec 20 '10 at 21:59
  • @eflat: Try using grep --line-buffered -v ... without the while loop. – Dennis Williamson Dec 20 '10 at 22:57

MultiTail has an option to do that:

--beep-interval x
Let the terminal beep for every x-th line processed. Press 'i' in the main menu to see how many times it beeped.

  • Cool app I'll make note of perhaps for future use. Thx. – eflat Dec 20 '10 at 20:55

This answer is slightly off to the side of your question but that's as much as I can help.

First I don't know of a simple way for tail or putty to alert you when data gets moving.

Second you need to enable beeps in Putty: check the option to pass on any bell call from the terminal session (check your settings -> terminal -> Bell). You may want to select a wav file there (or select 'flash the screen' for testing purposes).

Test it by typing control-G in the putty terminal window. So now you should have a bell that works.

Lastly, one option might be to pipe your tail to some script that checks the time for each line input (awk, perl or ruby come to mind, though I'm sure the shell would do just as well) and output a \x07 to /dev/stderr if the time difference between two consecutive outputs is greater than a given number of seconds.

For example:

(yourscript) | awk '{pt=t; t=systime(); if ((t-pt)>10) {printf "\x07" > "/dev/stderr"}; print}'


(echo a; sleep 4; echo b; sleep 9; echo c; sleep 12; echo d; sleep 8; echo e) | awk '{pt=t; t=systime(); if ((t-pt)>10) {printf "\x07" > "/dev/stderr"}; print}'

Change 10 in the awk script to the amount of seconds you want to wait for data before beeping the terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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