APScheduler:是一个任务定时执行的模块,定时调度自己的任务,比系统提供的定时服务灵活很多
可以采用两种方式添加任务,调用add_job()方法或使用scheduled_job()装饰器。
调用add_job方法:
使用装饰器:
cron表达式说明
Expression | Field | Description |
* | any | Fire on every value |
*/a | any | Fire every a values, starting from the minimum |
a-b | any | Fire on any value within the a-b range (a must be smaller than b) |
a-b/c | any | Fire every c values within the a-b range |
xth y | day | Fire on the x -th occurrence of weekday y within the month |
last x | day | Fire on the last occurrence of weekday x within the month |
last | day | Fire on the last day within the month |
x,y,z | any | Fire on any matching expression; can combine any number of any of the above expressions |
官方文档:http://apscheduler.readthedocs.org/en/latest/index.html