Skip to content

Instantly share code, notes, and snippets.

@mlandauer
Created May 7, 2015 01:40
Show Gist options
  • Save mlandauer/5d0a0725fe2232c4fd6a to your computer and use it in GitHub Desktop.
Save mlandauer/5d0a0725fe2232c4fd6a to your computer and use it in GitHub Desktop.
Monitor number of open file handles for a process over time
#!/bin/bash
# Provide pid of process for which you want to monitor the number of file handles
# You probably want to use it somewhat like this
# ./file_handle_mon.sh 1877 | tee file_handle_mon.out
while [ 1 ]
do
number=$(lsof -p $1 | wc -l)
date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "$date,$number"
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment