LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-23-2013, 01:30 AM   #1
jojanmpaul
Member
 
Registered: Sep 2012
Location: Bangalore
Posts: 80

Rep: Reputation: Disabled
File deletion not recovering the space on the disk.


I have done rm -rf nohup.out file from the linux server in-order to make some disk-space because of lack of space in the server. But I surprised by seeing the following,

ll -h nohup.out
-rw------- 1 user1:user1 54G Dec 13 02:29 nohup.out

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 226G 219G 0 100% /
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 2G 0 2G 0% /dev/shm

rm -rf nohup.out

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 226G 219G 0 100% /
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 2G 0 2G 0% /dev/shm

but file nohup.out got deleted.

I later able to make space in the disk by deleting other files. Is ll -h was showing wrong? Any one can explain why it has been happened.
 
Old 12-23-2013, 03:08 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by jojanmpaul View Post
I have done rm -rf nohup.out file from the linux server in-order to make some disk-space because of lack of space in the server.

Is ll -h was showing wrong? Any one can explain why it has been happened.
The scenario you describe is possible when a running process is still writing to the nohup.out file. Even though the file is not visible, it is still kept open and the space it occupies isn't freed until the process writing to it stops.

You might be able to find which process is keeping the file open by running (you might need root privileges):
Code:
lsof | grep nohup.out

Last edited by druuna; 12-23-2013 at 04:14 AM. Reason: Fixed a typo
 
Old 12-23-2013, 03:47 AM   #3
Jostekk
LQ Newbie
 
Registered: Jan 2013
Location: Brønnøysund, Norway
Distribution: RHEL
Posts: 1

Rep: Reputation: 0
If stopping the process is not an option, you can try just emptying the file:

Code:
>nohup.out
This will free up the space. The process will still write to the file, so you have to expect that the file will start growing again.
 
Old 12-23-2013, 04:04 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
@Jostekk: I'm not sure you can do that if the nohup.out file has already been deleted by the user. I suspect that > nohup.out will create a new file which isn't associated with the process that holds open the "original" nohup.out file.

Your solution will work if the file hasn't been deleted yet.
 
1 members found this post helpful.
Old 12-23-2013, 09:16 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,624

Rep: Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578Reputation: 1578
Quote:
Originally Posted by druuna View Post
I'm not sure you can do that if the nohup.out file has already been deleted by the user. I suspect that > nohup.out will create a new file which isn't associated with the process that holds open the "original" nohup.out file.
If you determine what process is holding the file open (lsof will show deleted files), you can read and write the file via its link in the /proc/{PID}/fd/ directory.
 
Old 12-23-2013, 09:33 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by rknichols View Post
If you determine what process is holding the file open (lsof will show deleted files), you can read and write the file via its link in the /proc/{PID}/fd/ directory.
Yes, that will work.

I would think though that one would prefer to stop the process and restart it (with or without the nohup.out file). After a while one might forget that the actual file was deleted and the token used in /proc/PID/fd/ needs to be used.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Recovering disk space lost due to dd error corbis_demon Linux - General 4 09-22-2009 09:43 PM
disk stats not updating after deletion of file.. disk full joecool118 Linux - General 2 04-10-2006 01:23 PM
help recovering from chkdsk.exe deletion of files? Lleb_KCir General 11 07-15-2005 01:30 PM
3Gb of disk space lost! Disk space problem or mother board conflicts with HDD Mistreated Linux - Hardware 4 12-06-2004 04:58 PM
Large tar file taking huge disk space in ext3 file system pcwulf Linux - General 2 10-20-2003 08:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration