Tuesday, 8 November 2011

LSOF Sort

Stolen from somewhere. How to sort lsof by file size or most files open. Useful when you have read speed issues, too many open files, too many large files open.


Check your read/write speeds:

hdparm -tT /dev/sda



sort by size:
sudo lsof -s | awk '$5 == "REG"' | sort -n -r -k 7,7 | head -n 50

 process with most files open:
sudo lsof | awk '$5 == "REG" {freq[$2]++ ; names[$2] = $1 ;} END {for (pid in freq) print freq[pid], names[pid], pid ; }' | sort -n -r -k 1,1 

No comments:

Post a Comment