我有一个无法访问cron命令的Flask Web托管.我怎样才能每小时执行一些Python函数?
我有以下导入错误
"ImportError:没有名为scheduler的模块"
当我运行以下python脚本时:
"""
Demonstrates how to use the blocking scheduler to schedule a job that execute$
"""
from datetime import datetime
import os
from apscheduler.scheduler import BlockingScheduler
def tick():
print('Tick! The time is: %s' % datetime.now())
if __name__ == '__main__':
scheduler = BlockingScheduler()
scheduler.add_job(tick, 'interval', seconds=3)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'$
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
Run Code Online (Sandbox Code Playgroud)
我已经安装了APS调度程序:sudo pip install apscheduler
我也升级了使用:sudo pip install apscheduler --upgrade还使用"sudo apt-get install update && sudo apt-get upgrade"升级了我的系统