From 9629b409daf0f56494039ca7fd92e04f08889a87 Mon Sep 17 00:00:00 2001 From: haotian <2421912570@qq.com> Date: Tue, 29 Jul 2025 03:41:50 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20start=5Fxxxx.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start_xxxx.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 start_xxxx.sh diff --git a/start_xxxx.sh b/start_xxxx.sh new file mode 100644 index 0000000..7f26a9e --- /dev/null +++ b/start_xxxx.sh @@ -0,0 +1,43 @@ +#! /bin/bash + +__conda_setup="$('/home/admin-root/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" +if [ $? -eq 0 ]; then + eval "$__conda_setup" +else + if [ -f "/home/admin-root/miniconda3/etc/profile.d/conda.sh" ]; then + . "/home/admin-root/miniconda3/etc/profile.d/conda.sh" + else + export PATH="/home/pro/miniconda3/bin:$PATH" + fi +fi +unset __conda_setup + +# 激活康达环境 +conda activate ocr + +# 进入到项目目录 +cd /home/admin-root/haotian/康达瑞贝斯/康达后台项目 + + +LOG_DIR="logs/robot" + +mkdir -p $LOG_DIR + +# 生成日志文件名(使用当前时间) +LOG_FILE="$LOG_DIR/robot_$(date +%Y%m%d_%H%M%S).log" + +# 检查当前程序是否已经正在运行. + +if pgrep -f "run_sync_robot.py" > /dev/null; then + echo "run_sync_robot 已经在运行中" + exit 1 +fi + +# nohup python run_sync_robot.py > "$LOG_FILE" 2>&1 & +# 注systemctl控制时最后的&要去掉,使得脚本一直在运行.脚本其实阻塞在这,后面都不会执行 +nohup python run_sync_robot.py > "$LOG_FILE" 2>&1 + +# 保存进程id +echo $! > "$LOG_DIR/robot.pid" +echo "WebSocket客户端已启动,日志保存在: $LOG_FILE" +echo "进程ID: $(cat $LOG_DIR/robot.pid)" \ No newline at end of file