Howtos / Articles

Live Monitoring of Log Files on Linux

The tail command which is found on almost all Linux distributions is used to output the last part of files. There is a parameter for the tail command that allows you to monitor a file, and continually output new lines from the file as they are added. This is especially handy for monitoring log files that are constantly being updated. The commands below can be used to continuously monitor log files.

Monitor a log file using tail:

$ tail -f /var/log/messages

Monitor a log file and cut the output at the console width so it doesn’t wrap:

This is handy for logs that are often long, and makes it hard to read on the screen. For example, Apache or Nginx log files.

$ tail -f /var/log/apache2/access.log | cut -b-$COLUMNS

Monitor multiple files at once:

$ tail -qf /var/log/apache2/*.log

This is handy for monitoring the access.log file and the error.log file at the same time.



Share this howto article!
  • Facebook
  • Twitter
  • Reddit
  • email

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>