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
[[email protected] ~]# 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.
[[email protected] ~]# 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:
[[email protected] ~]# systemctl restart httpd
PS. If you like this post please share it with your friends on the social networks using the buttons below.Thanks.