Skip to content

Instantly share code, notes, and snippets.

@kadishmal
Created August 28, 2014 05:47
Show Gist options
  • Save kadishmal/e03efafdd3996f5e6394 to your computer and use it in GitHub Desktop.
Save kadishmal/e03efafdd3996f5e6394 to your computer and use it in GitHub Desktop.
fd_count.sh: Watch open file descriptors count for a process.
#!/bin/sh
# Usage: sh fd_count.sh PID
RE='^[0-9]+$'
while :; do
clear;
for pid in `ps aux | awk '{print $2}'`; do
if [[ $pid =~ $RE ]] ; then
FCOUNT=`lsof -p $pid | grep -v " txt " | wc -l`;
echo "PID: $pid $FCOUNT";
fi
# done | sort -nk3 | grep $1;
done | grep $1;
sleep 5;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment