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.

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
add comment

3 Answers

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
add comment

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
add comment

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
add comment

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.