Scenario:
Suppose that you accidently removed Apache log file and you need to recover it. what you should do ? In this article we will show you how to recover a deleted Apache log file.
My deleted Apache log file is access_log
First step to do is to find the process number for main apache procees that owned by root
[root@webserver01 ~]# ps aux | grep httpd
In this case, the pid for the main apache process is 1201
Now let’s find all File Descriptors used by root HTTPD Process
Note the file descriptor of my deleted file is 10, to reover deleted access log file we need to copy the file number 10 using the following command.
[root@webserver01 ~]# cp /proc/1201/fd/10 /var/log/httpd/access_log
Finaly, restart the httpd service to check if everything works properly using the following command:
[root@webserver01 ~]# systemctl restart httpd
PS. If you like this post please share it with your friends on the social networks using the buttons below.Thanks.
1 comment
I wish I knew this method before! I had to use morpheusarch linux to recover data before when I could have just recovered the apache.log file this way thank you very much for sharing this 😀