As a system admin or even just a Linux enthusiast you will most likely find yourself dabbling within log files from time to time, while troubleshooting it can often help to watch the logs come into your physical files as they occur, instead of searching for them after the event.
One example might be the apache error.log for a web server, if you navigate to the directory you can run the following command to get a live output of the file.
tail -f ./error.log
Then replicate your problem and have a look at what log’s come through.
Some log files like the one above can be quite busy, especially something like a web access log on your live web server, so it’s also a good idea to filter your output using grep.
In the example below, I want to see all errors, but only for the web client having the errors (my PC)
tail -f ./error.log | grep 192.168.0.123
As you can see it’s just a simple case of piping the output into the grep command.
Once your done with either command just hit ctrl + c to cancel out of the live trace.
1 comments On How to view a live logfile in realtime, on Linux
How do I make this run when the desktop environment opens