User Tools

Site Tools


filesystem_usage_delete_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
filesystem_usage_delete_files [2015/07/02 08:18] – created luke7858filesystem_usage_delete_files [2024/05/23 07:26] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +== Clearing Deleted Files WITHOUT an Application Restart ==
 +Ever deleted a file and wondered why the disk space hasn't cleared?
 +\\
 +Chances are the application is still keeping the old file open.
 +\\
 +One way to "release" the file is to restart the application, however 99% of the time this is NOT ideal!!
 +\\
 +\\
 +1) First we find the file descriptor for the offending file.
 +\\
 +NOTE: you may be spammed with a lot of files from /tmp/ or similar directorys. Find the appropriate file for your situation. 
 <sxh bash> <sxh bash>
-lsof | grep 'Deleted'+find /proc/*/fd -ls | grep  '(deleted)' 
 +</sxh> 
 +Get the file descriptor from the deleted file, it will look similar to: 
 +<sxh bash> 
 +/proc/6755/fd/
 +</sxh> 
 +Once you have this we can delete the file by emptying it. Replacing the following command with the $pid and $fd we got above: 
 +\\ 
 +<sxh bash> 
 +> "/proc/$pid/fd/$fd" 
 +</sxh> 
 +Example: 
 +<sxh bash> 
 +> "/proc/6755/fd/6" 
 +</sxh> 
 +\\ 
 +\\ 
 +\\ 
 +== JUST ECHO NOTHING INTO THE FILE == 
 +Instead of deleting large files, simpy echo "" into it: 
 +<sxh bash> 
 +echo "" > /var/log/httpd/large_access.log
 </sxh> </sxh>
filesystem_usage_delete_files.1435825101.txt.gz · Last modified: 2024/05/23 07:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki