From a97ed5efbf2e5eb2457a4a1ab007d0aa711c58cd Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Tue, 10 Jun 2025 20:56:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0kill=5Fmain.sh?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=BB=A5=E7=BB=88=E6=AD=A2=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kill_main.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 kill_main.sh diff --git a/kill_main.sh b/kill_main.sh new file mode 100644 index 0000000..24ee028 --- /dev/null +++ b/kill_main.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + + +# -------- 可按需修改 -------- +TARGET="/opt/ql/DailyMotion/main.py" # 关键字:精确到脚本路径即可 +SIG="9" # 信号;默认 -9,想温和一点改成 15 +# -------------------------------- + + +pids=$(ps -eo pid,cmd | grep "$TARGET" | grep -v grep | awk '{print $1}') + +ppids=$(printf "%s\n" $pids | xargs -r ps -o ppid= -p | tr -s ' \n') + +# 合并并去重 +all=$(printf "%s\n%s\n" "$pids" "$ppids" | sort -u | tr '\n' ' ') + +if [ -z "$all" ]; then + echo "没有发现正在运行的 $TARGET" + exit 0 +fi + +echo "即将发送 SIG${SIG:-15} 到进程: $all" +kill "-${SIG}" $all + +echo "完成"