python定时执行任务
[*]from apscheduler.scheduler import Scheduler
[*]import datetime
[*]
[*]# Start the scheduler
[*]sched = Scheduler()
[*]
[*]
[*]def job_function():
[*] print "Hello World", 'start job1 at: ', datetime.datetime.now()
[*]
[*]def job_f():
[*] print "Hello World", 'start job2 at: ', datetime.datetime.now()
[*]
[*]
[*]print 'start to sleep'
[*]print 'wake'
[*]print datetime.datetime.now()
[*]sched.daemonic = False
[*]sched.add_cron_job(job_function,day_of_week='5', hour='19', minute='1',second='1')
[*]sched.add_cron_job(job_f,day_of_week='5', hour='20', minute='1',second='1')
[*]
[*]sched.start()
来自为知笔记(Wiz)
页:
[1]