首页 > 编程语言 > 详细

python定时执行任务

时间:2015-02-06 18:37:30      阅读:331      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!