luojunhui 3 недель назад
Родитель
Сommit
7e46f9aa4c
3 измененных файлов с 52 добавлено и 0 удалено
  1. 0 0
      account_explore_task.py
  2. 26 0
      sh/run_account_expore.sh
  3. 26 0
      sh/run_account_quality_analysis.sh

+ 0 - 0
account_crawler_task.py → account_explore_task.py


+ 26 - 0
sh/run_account_expore.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# 获取当前日期,格式为 YYYY-MM-DD
+CURRENT_DATE=$(date +%F)
+
+# 日志文件路径,包含日期
+LOG_FILE="/root/luojunhui/logs/account_explore_log_$CURRENT_DATE.txt"
+
+# 重定向整个脚本的输出到带日期的日志文件
+exec >> "$LOG_FILE" 2>&1
+if pgrep -f "python3 account_explore_task.py" > /dev/null
+then
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - account_explore_task.py is running"
+else
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - trying to restart account_explore_task.py"
+    # 切换到指定目录
+    cd /root/luojunhui/dev/LongArticlesJob
+
+    # 激活 Conda 环境
+    source /root/miniconda3/etc/profile.d/conda.sh
+    conda activate tasks
+
+    # 在后台运行 Python 脚本并重定向日志输出
+    nohup python3 account_explore_task.py >> "${LOG_FILE}" 2>&1 &
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - successfully restarted account_explore_task.py"
+fi

+ 26 - 0
sh/run_account_quality_analysis.sh

@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# 获取当前日期,格式为 YYYY-MM-DD
+CURRENT_DATE=$(date +%F)
+
+# 日志文件路径,包含日期
+LOG_FILE="/root/luojunhui/logs/account_quality_analysis_log_$CURRENT_DATE.txt"
+
+# 重定向整个脚本的输出到带日期的日志文件
+exec >> "$LOG_FILE" 2>&1
+if pgrep -f "python3 account_quality_analysis.py" > /dev/null
+then
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - account_quality_analysis.py is running"
+else
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - trying to restart account_quality_analysis.py"
+    # 切换到指定目录
+    cd /root/luojunhui/dev/LongArticlesJob
+
+    # 激活 Conda 环境
+    source /root/miniconda3/etc/profile.d/conda.sh
+    conda activate tasks
+
+    # 在后台运行 Python 脚本并重定向日志输出
+    nohup python3 account_quality_analysis.py >> "${LOG_FILE}" 2>&1 &
+    echo "$(date '+%Y-%m-%d %H:%M:%S') - successfully restarted account_quality_analysis.py"
+fi