Python scheduled task framework APScheduler 3.0.3 Cron example, apschedulercron
Reprinted: http://www.cnblogs.com/leleroyn/p/4501359.html
APScheduler is a Python scheduled task framework based on Quartz. It implements all the functions of Quartz and is very convenient to use. Provides tasks based on the date, fixed time interval, and crontab type, and can persist tasks. Based on these functions, we can easily implement a python scheduled task system.. Install
The installation process is very simple. It can be based on pip and source code.
Pip install apscheduler = 3.0.3
Or download the source code and run the following command:
Python setup. py install cron job example
# Coding = utf-8from apscheduler. schedulers. blocking import BlockingSchedulerfrom datetime import datetimeimport timeimport OS def tick (): 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' if OS. name = 'nt 'else 'C') try: scheduler. start () cipher T (KeyboardInterrupt, SystemExit): schedexit. shutdown ()