Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
文鑫
/
guduo_spider
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
7e5b9c63
...
7e5b9c639f2a61eb92195768e411bdd1057394a6
authored
2024-12-24 10:18:31 +0800
by
wenxin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
stop脚本修改
1 parent
8afa2bc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
stop.sh
stop.sh
View file @
7e5b9c6
#!/bin/bash
# 读取PID文件以获取进程ID
if
[
-f fastapi.pid
]
;
then
PID
=
$(
cat fastapi.pid
)
echo
"停止爬虫服务 PID->:
$PID
"
kill
-9
$PID
# 删除PID文件
rm fastapi.pid
else
echo
"未找到爬虫服务PID"
fi
# 指定你的Python脚本的完整路径
SCRIPT_PATH
=
"/topdraw/app/spider/guduo_spider/app/main.py"
# 查找与给定路径匹配的进程ID
PIDS
=
$(
pgrep -f
"
$SCRIPT_PATH
"
)
echo
"爬虫服务已停止"
\ No newline at end of file
if
[
-n
"
$PIDS
"
]
;
then
# 遍历所有找到的PID
for
PID
in
$PIDS
;
do
# 确认进程对应的命令行确实使用了指定路径下的脚本
CMD_LINE
=
$(
ps -p
$PID
-o
cmd
=
)
if
[[
"
$CMD_LINE
"
==
*
"
$SCRIPT_PATH
"
*
]]
;
then
echo
"Killing process:
$PID
"
kill
$PID
# 可选:检查kill命令是否成功
if
[
$?
-eq 0
]
;
then
echo
"Process
$PID
has been terminated."
else
echo
"Failed to terminate process
$PID
."
fi
else
echo
"Process
$PID
does not match the specified script path."
fi
done
else
echo
"No running processes found for script at:
$SCRIPT_PATH
"
fi
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment