杀死指定端口号的进程

1
2
3
4
5
6
7
8
# kill port 8090
pid=$(lsof -i:8090 | awk '{print $2}' | tail -n 1)
if [ "$pid" = "" ]; then
echo port 8090 is free
else
kill -9 $pid
echo kill $pid
fi