Capt. Crunch
Capt. Crunch

Reputation: 4790

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?

Upvotes: 4

Views: 2973

Answers (1)

user10678532
user10678532

Reputation:

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

Upvotes: 5

Related Questions