If you accidentally deleted the apache access log, we can recover before you restart the httpd server..

Steps:

First check the pid of the apache service by using the following command

[root@proxy httpd]# ps aux | grep httpd
root 2197 0.0 0.0 33832 10612 ? Ss Apr21 0:02 /usr/sbin/httpd
apache 2208 0.0 0.0 35140 9264 ? S Apr21 0:00 /usr/sbin/httpd
apache 2209 0.0 0.0 34844 7720 ? S Apr21 0:00 /usr/sbin/httpd
apache 2210 0.0 0.0 34844 7708 ? S Apr21 0:00 /usr/sbin/httpd
[root@proxy httpd]#

In this case, the pid for the main apache process is 2197

Now lets list the file descriptors:

[root@proxy httpd]# ls -lsa /proc/2197/fd
total 0
0 dr-x—— 2 root root 0 Apr 23 10:06 .
0 dr-xr-xr-x 7 root root 0 Apr 21 16:23 ..
0 lr-x—— 1 root root 64 Apr 23 10:06 0 -> /dev/null
0 l-wx—— 1 root root 64 Apr 23 10:06 1 -> /dev/null
0 l-wx—— 1 root root 64 Apr 23 10:06 10 -> /var/log/httpd/ssl_error_log
0 l-wx—— 1 root root 64 Apr 23 10:06 11 -> /var/log/httpd/access_log (deleted)
0 l-wx—— 1 root root 64 Apr 23 10:06 12 -> /var/log/httpd/proxy.pme-me.com-access_log
0 l-wx—— 1 root root 64 Apr 23 10:06 13 -> /var/log/httpd/ssl_access_log
0 l-wx—— 1 root root 64 Apr 23 10:06 14 -> /var/log/httpd/ssl_request_log
0 l-wx—— 1 root root 64 Apr 23 10:06 2 -> /var/log/httpd/error_log
0 lr-x—— 1 root root 64 Apr 23 10:06 3 -> /dev/urandom
0 lrwx—— 1 root root 64 Apr 23 10:06 4 -> socket:[12629] 0 lrwx—— 1 root root 64 Apr 23 10:06 5 -> socket:[12632] 0 lrwx—— 1 root root 64 Apr 23 10:06 6 -> socket:[12633] 0 lr-x—— 1 root root 64 Apr 23 10:06 7 -> pipe:[12649] 0 l-wx—— 1 root root 64 Apr 23 10:06 8 -> pipe:[12649] 0 l-wx—— 1 root root 64 Apr 23 10:06 9 -> /var/log/httpd/proxy.pme-me.com-error_log
[root@proxy httpd]#
[root@proxy httpd]#cp 11 /var/log/httpd/access_log
[root@proxy httpd]#service httpd restart

Now you can see the access_logs…

Written by Shameer

Hi..... I am working as System engineer ( Linux, Windows, Networking) for the past 5 years.. In this website, I am publishing my finding from great Google and also my trouble shooting and installation steps.. Best Regards, Shameer Mohammed. BTech Comp, RHCE, MCSE, CCNP