reprint: http://www.cnblogs.com/leleroyn/p/4501359.html
Apscheduler is a Python timed task framework based on Quartz, which realizes all the functions of quartz and is very convenient to use. Provides tasks based on date, fixed time interval, and crontab type, and can be persisted. Based on these features, we can easily implement a Python timed task system . Installation
The installation process is simple and can be based on PIP and source code.
Pip Install apscheduler==3.0.3
or download the source code, run the command:
Python setup.py Install Cron Job Example
#Coding=utf-8 fromApscheduler.schedulers.blockingImportblockingschedulerfrom datetimeImportdatetimeImport TimeImportOSdeftick ():Print('tick! the time is:%s'%DateTime.Now ())if __name__=='__main__': Scheduler=Blockingscheduler () scheduler.add_job (tick,'Cron', second='*/3', hour='*') Print('Press ctrl+{0} to exit'. Format (' Break' ifOs.name = ='NT' Else 'C')) Try: Scheduler.start ()except(Keyboardinterrupt, Systemexit): Scheduler.shutdown ()
Python timed task Framework Apscheduler 3.0.3 Cron Example