I am watching you

August 15th, 2006 mysurface Posted in Network, tail, watch | Hits: 37837 | 2 Comments »

To repeatly watching a certain file, such as log files, you can do that:

watch tail /var/log/messages

By default, this will be refresh every 2 seconds, and tail with list last 10 entries by default too. If you want to have specific refresh rate, you can do so:

watch -n 5 tail /var/log/messages

This will change the refresh rate to 5 seconds.

2 Responses to “I am watching you”

  1. To watch you log file, you can only do:
    tail -f /var/log/messages
    this lets you see the file in real time because the file is hold opened and new lines will be added to the end.

    But if you do it in a ssh connection, you may prefer the watch command because sessions without data may be terminated, Me too, so I would do something like
    watch -n 30 ‘tail -f /var/log/messages’
    But that won’t work, maybe because watch is waiting until the file descriptor is closed. I’m still searching for an solution, if someone know or find one, please post a comment here, thanks.

  2. wow, thanks

Leave a Reply