自动杀掉占用端口程序

This commit is contained in:
ZtRXR 2023-08-30 16:18:16 +08:00
parent 1659399f53
commit 5418e0ddd5

View File

@ -14,5 +14,14 @@ cp ./word.json ./.output/
# 4. 切换到 ./.output 目录
cd ./.output
port=3000
pid_list=$(lsof -t -i:$port)
# 杀死这些进程
for pid in $pid_list; do
echo "Killing process with PID $pid"
kill $pid
done
# 5. 执行 node ./server/index.mjs
node ./server/index.mjs