增加sh内存检查python的脚本
This commit is contained in:
23
sh/weblessie-server-01/kill_lessie_sourcing_agents.sh
Normal file
23
sh/weblessie-server-01/kill_lessie_sourcing_agents.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 从参数获取端口号
|
||||
PORT=$1
|
||||
|
||||
# 判断是否传入参数
|
||||
if [ -z "$PORT" ]; then
|
||||
echo "❌ 错误:请在执行时指定端口号,例如: sh kill_lessie_sourcing_agents.sh 8000"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 查找占用端口的进程 PID
|
||||
# PID=$(lsof -t -i:$PORT)
|
||||
PID=$(lsof -iTCP -sTCP:LISTEN -nP | awk -v port=":$PORT" '$9 ~ port"$" {print $2}' | sort -u)
|
||||
|
||||
if [ -n "$PID" ]; then
|
||||
echo "发现端口 $PORT 的进程,PID=$PID"
|
||||
echo "正在关闭进程..."
|
||||
kill -9 $PID
|
||||
echo "进程 $PID 已经被杀掉,端口 $PORT 已释放。"
|
||||
else
|
||||
echo "端口 $PORT 没有正在运行的进程。"
|
||||
fi
|
||||
Reference in New Issue
Block a user