summarylogtreecommitdiffstats
path: root/killport.sh
blob: 39bdd997bfd9bd35cc711ee4d5485f5d8d50b071 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

if [ "$#" -ne 1 ]; then
    echo "Usage: $(basename "$0") <port>"
    exit 1
fi

PORT=$1

PID=$(sudo lsof -t -i :"$PORT" 2>/dev/null)

if [ -z "$PID" ]; then
    echo "No process found listening on port $PORT"
    exit 1
fi

sudo kill -9 "$PID"
echo "Process with PID $PID listening on port $PORT has been force-killed."