Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I'm cleaning up an absolute mess of files - and have 75 gig of files which I'm not sure if they're being accessed through apache (and if they are, they're likely behind a maze of redirects) - I've duplicated the files, but with a new structure as the old structure was not coping with so many sub-folders.

What I would like to do, is log ONLY access to files beyond a certain path on the file-system /home/httpd/vhosts/sitename/httpdocs/hugedirectory/ so I can see if it's safe to delete them and recover some space.

share|improve this question
up vote 1 down vote accepted

Keep it simple. Use grep on your log file to filter out everything except the directory you're interested in.

grep 'GET /hugedirectory/' /var/log/apache2/sitename.access.log

Apache doesn't have a good way to separately log requests beyond the VirtualHost level. If you really want to have apache log directly to a separate log file, you could accomplish that with a custom logging script and pipe apache's access log to it. The CustomLog directive can specify a program which apache will start and write log data to that program's stdin, where you could then do some basic parsing and write the log files yourself.

Seriously though, just use grep.

share|improve this answer

Easiest solution is probably to enable logging in Apache, then filter the logs for the path. Not as elegant as only logging for some files, but probably simpler.

share|improve this answer

You should be able to parse-through your apache logs, looking for entries that match the base path (/var/www/html/hugedir may be /hugedir in the logs).

If after some amount of time (determinable by you, of course), you see no matches, it should be safe.

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.