Login | Sign up

May 26


0

Watching your logs in real time

Comments (0)

It can be very useful to see logged messages as they are logged. You can get a better feeling for what event triggered the message. You can easily view appended log messages using a basic Linux command, tail.

Sometimes when setting up new services or when troubleshooting a problem, you want to watch your log files as they grow. You want to see each line that gets added to the log as it is added. You can easily do this using one simple Linux command, tail -f

The tail command displays the last 10 lines of a file by default. You can change it to display more or less. The -f option makes the command "follow" the file. This means as things are appended to the end of the file, they are displayed on your screen. To stop following the file, simply press Ctrl+C

For example, if our apache web server is displaying errors when you try to load a page, you could follow its error log and then intentionally trigger the error by visiting the page giving the error.

  1. tail -f error_log

This will start by displaying the last 10 lines of the error_log and then as lines are added, they will be displayed as well.


Comments

There are no comments yet.


Post a new comment

Note: Items marked * are required fields

Post a comment

You must login before you can do that.

If you don't have an account, register for free. It's completely private.

Why register

  • rate posts and comments
  • ask questions about posts
  • request new topics/tutorials
  • mark posts as favorites to easily find them again