4

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?

Capt. Crunch
  • 4,490
  • 6
  • 32
  • 38
  • 4
    Does "stat - L path" work? Alternatively, the "lsof" might give you the info you need. – janneb May 22 '19 at 06:34
  • 2
    -L flag is possible shortest answer. stat without it gives wrong result, "stat -L $file" is right. Also, stat function in node, python and golang show right size too. – quant2016 Jan 25 '20 at 10:22

1 Answers1

4

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