Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Our analytics software monitors the HTML pages that we're serving quite nicely (through embedded javascript) but we have a few image files that are not included in these reports as they're not attached to any HTML. Knowing the file's name/path, I'm looking for quick (and dirty if necessary) way to identify how many times a given image was served by Apache on each Day (or hour?).

share|improve this question
up vote 1 down vote accepted

You will need to look at your particular log format, but as an example:

grep '/foo.jpg' /var/log/access.log | grep '11/May' | wc -l
share|improve this answer
i'm using: grep -c "/images/foo.jpg" /var/log/apache2/access_log and it gives me the count – Meltemi May 13 '10 at 15:57

Quick and dirty: grep for the image in the access log.

Number of times in a day = number of lines containing that pattern (assuming you roll your logs daily).
Number of times in an hour/minute/morning/afternoon/etc. gets a bit more complex but is still easily accomplished with some creative perl or shell scripting (the particulars of which depend on your log format)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.