Jan 23, 2013

f Comment

What's the Unix Command to Display the Content of a File as it is being Written?

Amazon One day I forgot this wonderful Unix command and I was amazed I could not find it on Google. Later I recovered this Unix command and thought I'd write a post about it.

This Unix command should work in all flavors of Unix or Linux distribution. I've run the command on many Unix and Linux OS versions and have never failed.
What is the command about?
I'd like to show the content of a file as it is being written. For example my web server process keeps writing to the web access log, and I'd like to watch who are accessing my web server by constantly monitoring the web log as it rolls.

The Linux command is the following, assuming the log location is /usr/apache/log/access.log:

tail -f /usr/apache/log/access.log
Use the Unix command 'tail -f' on any text file which has more content produced by another process. And you will see that the Unix terminal hangs and you see more content being displayed automatically as the content is being generated by that separate process!

If no process is writing to that file then the Linux terminal would just keep hanging until you forcefully quit, for example, via Control-C.
Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael