agri_xumu/forever.py

17 lines
340 B
Python
Raw Normal View History

2024-03-02 10:38:32 +08:00
import schedule
import time
import subprocess
def job():
2024-03-02 10:42:23 +08:00
subprocess.Popen(['supervisorctl reload'], shell=True)
2024-03-02 10:38:32 +08:00
print("任务执行了!当前时间:", time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
# 每半小时执行一次
schedule.every(1).minutes.do(job)
while True:
schedule.run_pending()
time.sleep(1)