File deletion not recovering the space on the disk.
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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,
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 03:14 AM.
Reason: Fixed a typo
@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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.