Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Kinda server noob. Is there a simple command to run on server access logs to track downloads of a particular file? Running Ubuntu 10.04.

share|improve this question

2 Answers 2

$ grep "/path/to/file" /var/log/httpd/access.log | wc -l

That looks for entries in your access log for '/path/to/file' and gives you a count of those lines. Run it against more logs for more days.

share|improve this answer

As Bill Weiss suggested, though older files are compressed, run zgrep on them. You can also use tail to see requested files in real time:

tail -f /var/log/httpd/access.log | grep "/path/to/file"

or to monitor multiple files:

tail -f /var/log/httpd/access.log | grep -E "(/path/to/file|/path/to/other/file)"
share|improve this answer

Your Answer

 
discard

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.