LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-26-2012, 08:06 AM   #1
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
how to recover deleted apache access log without using any Recovery tool


hI all,
Today one of my webserver unfortunately i had deleted off apache access log .As the resullt i could int able to start apache .I had created access_log in /etc/httpd/log/access_log and started the application .But anyone can help me how can i recover the previous deleted access_log without using any sort of recover tool
 
Old 05-26-2012, 08:32 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If you delete a file while it is still opened on some fle descriptor you can easily copy it out. If a process is stopped then even if you delete it remnants of a large file may still be spread across file system free space until they are reclaimed again but
Quote:
Originally Posted by arun5002 View Post
i had deleted off apache access log . (..) I had created access_log in /etc/httpd/log/access_log and started the application .
...by doing that you successfully thwarted recovery of the files contents. While lessons learned the hard way are usually the lessons you don't forget it doesn't have to be that way. Next time best ask before you do something.
 
Old 05-27-2012, 03:04 AM   #3
jayakumar01
Member
 
Registered: Nov 2011
Posts: 106

Rep: Reputation: Disabled
hi unspawn ,

Quote:
If you delete a file while it is still opened on some file descriptor you can easily copy it out
.

How can i find the log is opened in some file descriptor
 
Old 05-27-2012, 04:06 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Find out the PID with 'pgrep name_of_process' or '\ps -C name_of_process', long-list name_of_process' /proc/PID/fd/ directory checking for the "(deleted)" text, then 'cp /proc/PID/fd/file_descriptor_nr /path/to/directory' (ensure /path/to/directory has enough free space to hold the file). To find all deleted files that are still in use use something like 'lsof -Pwln|grep deleted'. Automating the latter may look something like 'lsof -Pwln|awk '/\(deleted/ {print "/proc/"$2"/fd/"$4" "$9}'|while read FD DELF; do echo "cp ${FD/u/} /path/to/directory/$(basename $DELF)"; done;'.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleted access.log file from squid evocage Red Hat 3 08-24-2011 03:18 AM
In Apache server, How to change log file location and log format for access log fil? since1993 Linux - Server 1 08-19-2009 04:14 PM
pls recommend free data recovery tool, 16G file deleted, windows version also OK parv Linux - Software 1 01-15-2009 12:18 AM
Apache log parser tool manojbarot1 Linux - Software 2 01-03-2008 12:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration