Last active
February 21, 2023 10:46
-
-
Save TomK/b8c5bebe1e29f62d3ecff7e5223c8ff6 to your computer and use it in GitHub Desktop.
What's running on a specified port?
This file contains 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
# What's running on a specified port? | |
# https://gist.github.com/TomK/b8c5bebe1e29f62d3ecff7e5223c8ff6 | |
if [ -z "$1" ]; then | |
echo 'You must specify a port' | |
exit 1 | |
fi | |
PIDS=$(lsof -nP -i:$1 |grep LISTEN |awk '{print $2}') | |
for PID in $PIDS; do | |
echo "[$PID] $(ps -p $PID -o command |tail -n1)" | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment