Python scheduled task framework APScheduler 3.0.3 Cron example, apschedulercron

Source: Internet
Author: User

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 ()

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.