Python timed task Framework Apscheduler 3.0.3 Cron Example

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.