How to actively monitor a text / log file in linux

Sometimes when your developing and debugging scripts you need to check your error log file to see what might be failing. In the past I’ve used the cat command to just display the last X entries of the log. For whatever reason today it stopped working and gave me a strange error.
sudo cat tail -10 error.log
cat: invalid option -- '1'
Try `cat --help' for more information.

Well I didn’t end up finding out why, rather I found a way to have it watch the file and update me every interval of seconds using this code:

watch -n 2 tail -n 15 mylogfile.txt

Basically watch is set to refresh every 2 seconds, and tail is pulling back 15 results and mylogfile.txt is the name of your file.


Posted in Development and tagged .

Leave a Reply