Linux View / Display a Logfile In Real Time on Screen

by on October 2, 2007 · 2 comments· LAST UPDATED November 26, 2013

in , ,

I would like to see my php or apache web server log files in real time. How do I see a log file in real time including all incoming logs on Linux using ssh based session?

You need to use the tail command which output the last part of files in real time including all incoming logs to a standard output device such as screen. This is useful to:

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion time2m
  1. View log files in real time.
  2. Debug server problems.
  3. Troubleshoot security issues.
  4. Monitor spammers, ip-address, scripts and more.

tail -f file-name command syntax

The basic syntax is:

 
tail fileName
tail /path/to/log/file
tail [options] /path/to/log/file
 

If your log file name is /var/log/lighttpd/access.log, enter:
tail -f /var/log/lighttpd/access.log

If your php log file name is /var/log/lighttpd/scripts.log, enter
tail -f /var/log/lighttpd/scripts.log
Sample outputs:

 
 47 -> 400
2013-11-24 21:47:29: (request.c.622) invalid character in key GET /nixcraft/linux/docs/uniqlinuxfeatures/lsst HTTP/1.1
Host: cyberciti.biz
Accept: */*
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0 FirePHP/0.7.4
 
 /5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0 FirePHP/0.7.4
 
 47 -> 400

You will get a scrolling view of the /var/log/lighttpd/scripts.log for all incoming entries on screen. To stop simply hit CTRL+C. Please note that you may need to login as root user to view log files.

Recommend readings
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 2 comments… read them below or add one }

1 Rogha December 15, 2009 at 11:14 pm

how do to view this tail -f log.log on a web?

Reply

2 Romero May 7, 2011 at 12:37 pm

not that simple, u must use ajax.

Reply

Leave a Comment

Tagged as: , , , , , , , ,

Previous Faq:

Next Faq: