pip install apscheduler==2.1.2
安装完成后,打开django web 项目的views.py 增加以下内容:
from apscheduler.scheduler import Scheduler
"""定时将rollingRegression分析生成的图片文件夹下的图片全部删除"""
sched = Scheduler()
@sched.interval_schedule(seconds=60)
def delStatic_rollingRegression():
for file in os.listdir('./'):
path_file = os.path.join('./', file)
if os.path.isfile(path_file):
os.remove(path_file)
sched.start()