Find and remove large files that are open but have been deleted | find /folder/ -printf '%s %p \n' | sort -nr | head -10
Find top large files:
find /folder/ -printf '%s %p \n' | sort -rh | head -10
To truncate it:
find /folder/ -printf '%s %p \n' | sort -rh | head -10
To truncate it:
: > /path/to/the/file.log
If it was already deleted, on Linux, you can still truncate it by doing:
: > "/proc/$pid/fd/$fd"
Where
$pid
is the process id of the process that has the file opened, and $fd
one file descriptor it has it opened under (which you can check with lsof -p "$pid"
.
If you don't know the pid, and are looking for deleted files, you can do:
lsof -nP | grep '(deleted)'
Comments
Post a Comment