Skip to content

Instantly share code, notes, and snippets.

@kartikeyap
Created June 14, 2018 10:14
Show Gist options
  • Select an option

  • Save kartikeyap/a114723e20e55257ec0c5da35b1fb74c to your computer and use it in GitHub Desktop.

Select an option

Save kartikeyap/a114723e20e55257ec0c5da35b1fb74c to your computer and use it in GitHub Desktop.
lsof -P -i tcp | awk '{print $2,$4,$9}' | tr -d 'u' | sort -u| grep -v PID | while read pid fd details; do curr_time="$(date +%s)"; birth_time="$(stat --printf "%Z" /proc/${pid}/fd/${fd})"; age=$((curr_time-birth_time)); if (( $age > 0)); then echo "${age} seconds /proc/${pid}/fd/${fd} ${details}" ; fi; done | sort -n -k1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment