wangkun 2 years ago
parent
commit
e34d059da8
2 changed files with 5 additions and 8 deletions
  1. 2 5
      main/run_zhihu_hot.py
  2. 3 3
      zhihu.sh

+ 2 - 5
main/run_zhihu_hot.py

@@ -15,14 +15,11 @@ class Main:
     @classmethod
     def main(cls, log_type, env):
         while True:
-            # if 22 >= datetime.datetime.now().hour >= 8:
             Common.logger(log_type).info('开始抓取知乎热榜\n')
             ZhihuHot.get_hot_feeds(log_type, env)
             Common.del_logs(log_type)
-            Common.logger(log_type).info('随机休眠 60-180 秒\n')
-            time.sleep(random.randint(60, 60*3))
-            # else:
-            #     pass
+            Common.logger(log_type).info('休眠 1 小时\n')
+            time.sleep(3600)
 
 
 if __name__ == '__main__':

+ 3 - 3
zhihu.sh

@@ -11,9 +11,9 @@ echo "$(date "+%Y-%m-%d %H:%M:%S") 进程已杀死!"
 echo "$(date "+%Y-%m-%d %H:%M:%S") 正在更新代码..."
 cd /data5/wangkun/crawler_zhihu/ && git pull origin master --force
 echo "$(date "+%Y-%m-%d %H:%M:%S") 代码更新完成!"
-
+source /etc/profile
 echo "$(date "+%Y-%m-%d %H:%M:%S") 正在重启服务..."
-nohup python -u main/run_zhihu_hot.py >>./nohup.log 2>&1 &
-nohup python -u main/run_zhihu_follow.py >>./nohup.log 2>&1 &
+nohup python3 -u main/run_zhihu_hot.py >>./nohup.log 2>&1 &
+nohup python3 -u main/run_zhihu_follow.py >>./nohup.log 2>&1 &
 echo "$(date "+%Y-%m-%d %H:%M:%S") 服务重启完毕!"
 exit 0