agri_xumu/forever.py

20 lines
452 B
Python

import schedule
import time
import subprocess
def job():
subprocess.Popen(['supervisorctl reload'], shell=True)
print("任务执行了!当前时间:", time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
# 每半小时执行一次
schedule.every(10).minutes.do(job)
try:
while True:
schedule.run_pending()
time.sleep(1)
except Exception as e:
print(e)
subprocess.Popen(['supervisorctl reload'], shell=True)