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 am trying to find out how many times a specific web file has been accessed. I have root access to the server, but not sure where to look. The only place I have looked in is /home/FTPUSER/access-logs which is a sym link to /usr/local/apache/domlogs/perrysre and that access log only has 1 day of data in it.

Any help would be greatly appreciated.

share|improve this question
which OS are we talking about? Or distro if linux – drAlberT Sep 9 '09 at 8:26
I am using CENTOS – icelizard Sep 9 '09 at 9:16
up vote 2 down vote accepted

If your access log contains only a day's worth of data it is presumably being rotated each day. You'll need to work out how this is configured. If you're using Linux it might be with logrotate -- look in /etc/logrotate.d/ or /etc/logrotate.conf if they exist. On FreeBSD log rotation is configured in /etc/newsyslog.conf.

Apache might also be doing it via rotatelogs. If so, this'll be set up in a CustomLog line in the server configuration (httpd.conf), which could be in /etc/httpd or, more likely given your log location, /usr/local/apache/conf.

If none of this works ask the person who configured it!

share|improve this answer

I think, since from your question I can't argue the system settings you are operating in, a universal way to find files used by a process can do the trick.

Try using lsof -p <PID_OF_APACHE_DAEMON>.

You can retrieve the PID in a number of ways, one can be looking at netstat -tlnop output, another is using lsof -i, and so on.

This is a POC that can work:

lsof -p $(lsof -i :80 | head -2 | tail -1 | awk '{print $2}') | grep log

httpd   2618 root  mem    REG  253,0           64072 /usr/lib/httpd/modules/ (path inode=63267)
httpd   2618 root  mem    REG  253,0           64070 /usr/lib/httpd/modules/ (path inode=63265)
httpd   2618 root    2w   REG  253,2    1461  720904 /var/log/httpd/error_log
httpd   2618 root    6w   REG  253,2    1461  720904 /var/log/httpd/error_log
httpd   2618 root    7w   REG  253,2    4483  720899 /var/log/httpd/access_log

Here I have assumed your apache daemon is listening on the standard tcp port 80 of course.

share|improve this answer

all Apache logs are usually stored in :



/var/log/apache(2)/customs .log

a nice commande I like in order to count something :

cat /var/log/apache2/access.log | grep WORD-TO-LOOK | wc -l

then you will have a number. Let's suppose you have a FTP logs, and every time john connects, there is a line 'John opened a session'. So you will do :

cat /var/log/ftp.log | grep John opened a session | wc -l

will give you how many times did John open a session. If you want period of times,etc you could also do it

share|improve this answer
Why don't grep directly the file avoiding cat? – drAlberT Sep 9 '09 at 8:35
You need to quote 'John opened a session' because it contains spaces. And "grep -c 'John opened a session' /var/log/ftp.log" avoids both cat and wc! – markdrayton Sep 9 '09 at 8:37
thanks for the new trick :) – Razique Sep 9 '09 at 11:06

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.