Tag: lsof linux
For a lack of LSOF
by sudo on Aug.28, 2012, under Linux
When you have to deal with system that lacks lsof and cannot be easily installed, you can run the following to show information regarding currently open file handlers.
ls -l `ls -l /proc/*/fd/ 2>/dev/null | grep ">" | cut -d ">" -f 2 | grep "/" | sort | uniq`
If the culprit of disk space usage has already been deleted, you’ll find the following in your output.
ls: /var/log/openvswitch/ovs-vswitchd.log.1: No such file or directory
ls: (deleted): No such file or directory
———
Teran came up with the following.
for file in `ls -l /proc/*/fd/* | grep deleted | awk '{print $9}'`; do echo -n "$file "; ls -l $file | awk '{print $11}' | tr -d '\n'; stat -L $file | grep Size; done