Created
March 18, 2016 06:11
-
-
Save jesuscast/f8e752032186f24b8fa9 to your computer and use it in GitHub Desktop.
Finds the id of the process that has the most open files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HIGHEST_PROCESS='' | |
| HIGHEST_PROCESS_FILES=0 | |
| ps aux | awk 'NR > 1' | awk '{ print $2 }' > tmp.txt | |
| while read -r process_element; do | |
| process_pid="$process_element" | |
| number_of_files=`lsof -p $process_pid | wc -l | awk '{ print $1 }'` | |
| if [ $number_of_files -gt $HIGHEST_PROCESS_FILES ]; then | |
| HIGHEST_PROCESS=$process_pid | |
| HIGHEST_PROCESS_FILES=$number_of_files | |
| fi | |
| done < 'tmp.txt' | |
| rm 'tmp.txt' | |
| echo "pid with most open files $HIGHEST_PROCESS" | |
| echo "number of open files $HIGHEST_PROCESS_FILES" | |
| echo "information `ps -p $HIGHEST_PROCESS | awk 'NR > 1'`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment