apacheaccess-log

Apache Redhat list how many times /foo/ was hit from command line


so far I have not been able to find an answer online or in any book. I would like to count how many times /foo/ was hit on my site. If anyone could help, Thank you!


Solution

  • Enter this on a command line:

    grep -c '/foo/' /var/log/httpd/access_log 
    

    This will show the number of counts of "/foo/" inside of your apache acess log file.

    There are more access log files:

    access_log.2 access_log.4
    access_log.1 access_log.3 access_log.5

    If you want to see the result from older entries, then you can use

    grep -c '/foo/' /var/log/httpd/access_log*
    

    Result:

    /var/log/httpd/access_log:46
    /var/log/httpd/access_log.1:85
    /var/log/httpd/access_log.2:46
    /var/log/httpd/access_log.3:103
    /var/log/httpd/access_log.4:70
    /var/log/httpd/access_log.5:177
    

    The path depends on your Redhat version.

    http://www.itninja.com/blog/view/mysql-and-apache-profile-log-path-locations