How to recover file in linux. In this post explain about how to recover apache log file from running application.
Overview of Apache log file
Once upon a day, by mistake, I delete log file from a running apache application, now problem set is how can I recover that log without any 3rd party recovery tools.
we are going to discuss if we can recover that file what is the step of recovery.
Those who are very experienced in linux
must know how to do this.
For example, I have an application “demo” that is running that that creates a log file “my-demo-log.txt’ and in running the application my mistake user delete the "my-demo-log.txt"
file .
Steps to recover log file
Recover a file in Linux, in this example recovering apache log file
Step: Find the process Id of your process, in my case “demo” processes.
# ps aux | grep demo shakti 8071 0.0 0.3 3878 10987 ? Ss 13:01 0:00 /home/shakti/demo
So from above command we find the main process id of “demo” process.
Now we go to proc file system of that process id.
#ls -ltr /proc/8071/fd
that out of this command show your that soft link of your delete file and from here user can copy and recover your delete log file in linux.
# cp /proc/8071/fd/my-demo-log.txt /home/ -v
happy Learning 🙂 of recovring of deleted log file from Apache.