Skip to content

Commit e54ed8e

Browse files
committed
What's running on port
1 parent c049282 commit e54ed8e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

port

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Show process info for what's listening on a given port
4+
5+
if [[ -z $1 ]]; then
6+
echo "Usage: port-ps <port>" >&2
7+
exit 1
8+
fi
9+
10+
port=$1
11+
pids=$(lsof -n -ti ":$port" 2>/dev/null)
12+
13+
if [[ -z $pids ]]; then
14+
echo "Nothing listening on port $port"
15+
exit 0
16+
fi
17+
18+
for pid in $pids; do
19+
ps -p "$pid" -o pid,user,command
20+
done

0 commit comments

Comments
 (0)