Skip to content

Instantly share code, notes, and snippets.

@mtfelian
Created May 25, 2020 10:55
Show Gist options
  • Save mtfelian/4a2de905e2db45ca40916918e44e6ed7 to your computer and use it in GitHub Desktop.
Save mtfelian/4a2de905e2db45ca40916918e44e6ed7 to your computer and use it in GitHub Desktop.
Displays top10 processes by count of open files
cd /proc
for pid in [0-9]*
do
echo "PID = $pid with $(ls /proc/$pid/fd/ | wc -l) file descriptors"
done | sort -rn -k5 | head | while read -r _ _ pid _ fdcount _
do
command=$(ps -o cmd -p "$pid" -hc)
printf "pid = %5d with %4d fds: %s\n" "$pid" "$fdcount" "$command"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment