Pete Freitag Pete Freitag

Monitoring Log files in Realtime on Unix

Published on December 06, 2006
By Pete Freitag
linuxapple

Here's a handy trick for monitoring log files on unix, linux or mac's.

SSH on to your server then type:

tail -f /var/log/httpd/access_log

The above command will show you the last few lines of the log file, this is no suprise if your fimiliar with tail command. However the -f option will print to your console any new lines added to the log file in realtime. So you can get a live view of the traffic on your server.



logs unix commands tail

Monitoring Log files in Realtime on Unix was first published on December 06, 2006.

If you like reading about logs, unix, commands, or tail then you might also like:

Weekly Security Advisories Email

Advisory Week is a new weekly email containing security advisories published by major software vendors (Adobe, Apple, Microsoft, etc).

Comments

Multitail is even more useful.
It displays multiple logfiles in split windows on your console and can even merge several logfiles in one view or show you program output (eg. lsof -i)
Give it a go!
by Flo on 12/06/2006 at 4:54:50 PM UTC
I've also found it helpful to use grep if you want to filter your "realtime" tailed output by IP address, page name, etc.

tail -f /var/log/httpd/access_log | grep '192.168.1.100'
by Bernie Dolan on 12/07/2006 at 11:41:17 AM UTC
works on windows too, if you install cygwin and add C:\cygwin\bin to your path - http://www.cygwin.com/
by thad on 12/07/2006 at 12:24:35 PM UTC
How do tail on a log file that will be created in the current working directory?
by leofox on 11/18/2008 at 8:49:10 AM UTC
This is fantastic. Thanks for the tip :)
by Joe on 08/13/2010 at 4:48:31 PM UTC
This doesnt work in case of rolling logs. As soon as the log is archieved , the command still keeps the pointer on the archieved file and not on the new file. the following script is good and can help monitoring rolling logs.

http://www.buggybread.com/2012/03/log-monitoring-shell-script-to-send.html
by Vikas on 02/16/2013 at 12:16:17 PM UTC