Переглянути джерело

Merge branch '2024-11-01-luojunhui-article-exit-v1' of luojunhui/LongArticlesJob into master

luojunhui 8 місяців тому
батько
коміт
39586fd700
3 змінених файлів з 49 додано та 7 видалено
  1. 15 7
      config/crontab_backup
  2. 8 0
      run_article_title_exit_v1.py
  3. 26 0
      sh/run_article_title_exit_v1.sh

+ 15 - 7
config/crontab_backup

@@ -1,24 +1,32 @@
-# update read rate daily at 10:00 AM everyday
+# 0 10 * * * bash /root/luojunhui/LongArticlesJob/sh/run_update_account_avg_v3.sh
+
+# 每天凌晨4点执行账号冷启动任务
+0 4 * * * bash /root/luojunhui/LongArticlesJob/sh/run_account_cold_start_daily.sh
+
+# 每天上午11点执行文章退场 && 晋升任务
+30 10 * * * bash /root/luojunhui/LongArticlesJob/sh/run_article_title_exit_v1.sh
+
+# 每天 10 点执行前一天的阅读率均值代码
 0 10 * * * bash /root/luojunhui/LongArticlesJob/sh/run_update_account_read_rate_avg.sh
 
-# update account read avg at 10:40 AM everyday
+# 20 10 * * * bash /root/luojunhui/LongArticlesJob/sh/run_update_account_avg_v3.sh
+
 40 10 * * * bash /root/luojunhui/LongArticlesJob/sh/run_update_account_avg_v3.sh
 
-# check publish videos status at the 20 min of each hour
+# 每 20 分钟执行一次校验视频状态
 20 * * * * bash /root/luojunhui/LongArticlesJob/sh/run_check_video_status_hourly.sh
 
 
-# update published articles at 20:50 everyday
+# 每天 20 点 50 执行更新已发布文章任务
+
 50 20 * * * bash /root/luojunhui/LongArticlesJob/sh/run_update_published_articles_daily.sh
 
 
 # 每天上午 9:30 点,下午 2 点,晚上 7 点执行下架视频任务
+
 30 9 * * * bash /root/luojunhui/LongArticlesJob/sh/run_get_off_videos_three_times_per_day.sh
 
 0 14 * * * bash /root/luojunhui/LongArticlesJob/sh/run_get_off_videos_three_times_per_day.sh
 
 0 19 * * * bash /root/luojunhui/LongArticlesJob/sh/run_get_off_videos_three_times_per_day.sh
 
-# 每天上午8点执行账号冷启动任务
-0 8 * * * bash /root/luojunhui/LongArticlesJob/sh/run_account_cold_start_daily.sh
-

+ 8 - 0
run_article_title_exit_v1.py

@@ -0,0 +1,8 @@
+"""
+@author: luojunhui
+"""
+from flow_pool.exit_article_with_title import main
+
+
+if __name__ == '__main__':
+    main()

+ 26 - 0
sh/run_article_title_exit_v1.sh

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