GnomeTWEAK

 GnomeTWEAK


Lockergnome readers, SAVE 50% on the Computing Encyclopedia!
Are you looking for the ultimate computing resource? Discover the
Computing Encyclopedia from Smart Computing. Regular price $59,
SPECIAL OFFER for Lockergnome readers,
get your set TODAY, ONLY $29.95!

Page Accesses

If you’re running a web server on your machine, I’ve got a quick and easy command line tweak for you today to display the number of page requests for your site.

The following command will display how many times your index page has been accessed:

    grep “GET / HTTP” /var/log/httpd/access_log | wc -l

I know – it’s far from a log analyzer! But, it’s a good example of using builtin commands in Linux to retrieve data.

This line uses the grep program to parse through /var/log/httpd/access_log looking for the string “GET / HTTP”. /var/log/httpd/access_log is the default log file to record access requests on your server. It may vary from distribution to distribution, or you may have configured a different file as your httpd access log.

The results of the grep command are then piped to wc, a program used to print the number of bytes, words or lines in a file. The -l options specificies that we’re counting lines.

So, in short, you use grep to find all the instances of “GET / HTTP” (a page request) in your log and wc to count the number of lines returned by grep.

It’s a quick and easy tweak to check the number of hits to your web server.

Article Written by