From a97ed5efbf2e5eb2457a4a1ab007d0aa711c58cd Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Tue, 10 Jun 2025 20:56:53 +0800 Subject: [PATCH 1/4] =?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 "完成" From 52cee8b5b8e5a370b1e318879dbc45f044987d07 Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Tue, 10 Jun 2025 21:17:38 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96kill=5Fmain.sh?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=BB=A5=E4=BD=BF=E7=94=A8pgrep=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3ps=E5=91=BD=E4=BB=A4=E6=9F=A5=E6=89=BE=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kill_main.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/kill_main.sh b/kill_main.sh index 24ee028..2dc0bb7 100644 --- a/kill_main.sh +++ b/kill_main.sh @@ -6,13 +6,7 @@ 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' ' ') +pids=$(pgrep -f "$TARGET") if [ -z "$all" ]; then echo "没有发现正在运行的 $TARGET" From 44965351e9890d99c2e9d46e5e4bd7de782003d9 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Jun 2025 21:23:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kill_main.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 kill_main.sh diff --git a/kill_main.sh b/kill_main.sh old mode 100644 new mode 100755 From 1c482f2b1ad6d6b9a8c0658cf479178388a893df Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Tue, 10 Jun 2025 21:28:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dkill=5Fmain.sh?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=B8=AD=E7=9A=84=E5=8F=98=E9=87=8F=E5=90=8D?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BB=A5=E6=AD=A3=E7=A1=AE=E6=9F=A5=E6=89=BE?= =?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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kill_main.sh b/kill_main.sh index 2dc0bb7..c403fae 100755 --- a/kill_main.sh +++ b/kill_main.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - # -------- 可按需修改 -------- TARGET="/opt/ql/DailyMotion/main.py" # 关键字:精确到脚本路径即可 SIG="9" # 信号;默认 -9,想温和一点改成 15 @@ -8,12 +7,12 @@ SIG="9" # 信号;默认 -9,想温和一点改 pids=$(pgrep -f "$TARGET") -if [ -z "$all" ]; then +if [ -z "$pids" ]; then echo "没有发现正在运行的 $TARGET" exit 0 fi -echo "即将发送 SIG${SIG:-15} 到进程: $all" -kill "-${SIG}" $all +echo "即将发送 SIG${SIG:-15} 到进程: $pids" +kill "-${SIG:-15}" $pids -echo "完成" +echo "完成" \ No newline at end of file