码迷,mamicode.com
首页 > 编程语言 > 详细

python定时执行任务

时间:2015-02-06 18:39:34      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:

  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=‘19‘, minute=‘1‘,second=‘1‘)
  14. sched.add_cron_job(job_f,day_of_week=‘5‘, hour=‘20‘, minute=‘1‘,second=‘1‘)
  15. sched.start()





python定时执行任务

标签:

原文地址:http://www.cnblogs.com/highroom/p/2ea093ac7e11a8142de9da3f9147c7f2.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!