Python performs tasks on a timed basis

Source: Internet
Author: User

  
 
  1. from apscheduler.scheduler import Scheduler
  2. import datetime
  3. # Start the scheduler
  4. sched = Scheduler()
  5. def job_function():
  6. print "Hello World" , ‘start job1 at: ‘, datetime.datetime.now()
  7. def job_f():
  8. print "Hello World" , ‘start job2 at: ‘, datetime.datetime.now()
  9. print ‘start to sleep‘
  10. print ‘wake‘
  11. print datetime.datetime.now()
  12. sched daemonic = false
  13. sched add_cron_job ( job_function day _of_week = ' 5 ' , hour = "" minute = ' 1 ' second = ' 1 '
  14. sched.add_cron_job(job_f,day_of_week=‘5‘, hour=‘20‘, minute=‘1‘,second=‘1‘)
  15. sched.start()



From for notes (Wiz)

Python performs tasks on a timed basis

Related Article

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.