Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding size of deleted open file in Linux?

I'm aware of all the hoopla around deleted open files in Linux still hanging around and taking space on the file system.

What I'm after is to find the size of these deleted open files.

sudo find /proc/[0-9]*/fd -ls | grep '(deleted)' gives me the list but it results in information about the "virtual symbolic link" from the proc filesystem, not the deleted files.

Is there a way to get this information?

like image 306
Amos Shapira Avatar asked Oct 22 '25 06:10

Amos Shapira


1 Answers

This prints the /proc/[pid]/fd/[fd] path, its symlink target, and the size of the actual file:

find /proc/[0-9]*/fd -lname '*(deleted)' \
    -printf '%p => %l\t' -exec stat -Lc '%s' {} \; 2>/dev/null

There may be smarter ways to do it ;-)


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!