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?

1 answer

  • answered 2019-05-22 15:45 mosvy

    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 ;-)