import time
from apscheduler.schedulers.blocking import BlockingScheduler
def my_job():
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))
if __name__ == '__main__':
sched = BlockingScheduler()
# sched.add_job(my_job, 'interval', seconds=5) # 每隔5秒执行一次任务
sched.add_job(my_job, 'interval', minutes=5) # 每隔5分钟执行一次任务
# sched.add_job(my_job, 'interval', hours=5) # 每隔5小时执行一次任务
sched.start()
# print(sched.get_jobs())
原创文章,转载请注明出处:http://124.221.219.47/article/84653/