【发布时间】:2019-07-02 01:53:54
【问题描述】:
我能够通过 Non-Sucking Service Manager (nssm) 设置 Windows 服务,以便每 15 分钟运行一次我的 Python 脚本。似乎该服务已创建并正在“运行”,但没有迹象表明该脚本正在运行。当我从命令提示符运行时,脚本和计划运行得很好,所以我知道我的代码没有问题。
我有什么遗漏吗?
import schedule
from time import sleep
from datetime import datetime
def my_func():
#a bunch of code...
with open('log.text','a') as outfile:
outfile.write(f'Program ran at {datetime.now()}')
schedule.every(15).minutes.do(my_func)
while True:
schedule.run_pending()
sleep(1)
【问题讨论】:
标签: python windows windows-services scheduled-tasks nssm