July 23, 2009

tail -f vs less +F

When I was fist seen this command, I was thinking ohhhh god why I haven't seen this command long time back, this could have make my life much more easier.

tail -f /var/log/messages

The main advantages of tail -f is that, you can monitor logs real time it will keep on appending logs as it goes, but what if I have found one error and want to look back what went wrong, I have to quit the tail and open the file in VI or with less.

There comes the advantage of less +F, you can monitor logs real time it will keep on appending logs as it goes, and if I found error I can execute ctrl+c to stop appending real time log and can go back and check what went wrong, once I verified and can again start appending log by executing capital F
less +F /var/log/messages

This does the same thing as tail -f but it will also show the entire file, just press ctrl + c to navigate around the log file. When you want to view the log in real time again just type a capital F.

Click Here!