通过sh脚本查找某一个端口的进程并杀死
sh
#!/bin/bash
port=8080 # 将8080替换成你想要查找和杀死的端口号
# 查找端口的进程ID
pid=$(lsof -ti :$port)
# 杀死进程
if [[ -n "$pid" ]]; then
echo "Killing process $pid listening on port $port"
kill -9 $pid
else
echo "No process listening on port $port"
fi