summaryrefslogtreecommitdiff
path: root/killport
blob: d45264b3401277d3305bbf3654cf6bfabc7a576a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash


if  [ ! $1 ]; then
    echo "Please give a port"
    exit
elif [ $2 ]; then
    echo "Only 1 argument(port) need to be given"
    exit
elif $(kill $(lsof -t -i :$1) 2> /dev/null); then
    echo "Killed $(ps -p $(lsof -t -i :$1) -o comm=) with SIGTERM"
else
    echo "No process in port"
fi