APScheduler不会触发?

时间:2014-02-26 01:43:41

标签: python apscheduler

为什么工作不会触发?

我想每天01:00:00触发这份工作。

如果我将触发时间设置为上午10点并运行py脚本。它会工作。但凌晨1点,不要触发。

调用print_jobs(),

Jobstore default:

    grab_star_baidu_news (trigger: cron[hour='1', minute='0', second='0'], next run at: 2014-02-26 01:00:00)

    grab_star_baidu_news_title (trigger: cron[hour='1', minute='30', second='0'], next run at: 2014-02-26 01:30:00)

    film_info_2_db (trigger: cron[hour='3', minute='0', second='0'], next run at: 2014-02-26 03:00:00)

我的脚本(在Windows Server 2012上运行):

 from apscheduler.scheduler import Scheduler
 import apscheduler
 import sys

 sys.path.append("E:\data")
 sch = Scheduler(daemonic=False)

 @sch.cron_schedule(hour="1", minute="0", second="0")
 def grab_star_baidu_news():
     import BaiduNewsMx
     BaiduNewsMx.GrabMxBaiduNews()


 @sch.cron_schedule(hour="1", minute="30", second="0")
 def grab_star_baidu_news_title():
     import BaiduNewsTitleMx
     BaiduNewsTitleMx.GrabBaiduMxNewsTitle()

 @sch.cron_schedule(hour="3", minute="0", second="0")
 def film_info_2_db():
     import InfoToDb
     InfoToDb.InsertFilmInfo2Db()

 #Job listener for completed and miss.
 def job_listener(ev):
     if ev.exception:
         print(str(ev.exception))
     else:
         print(str(ev.job))


 def job_complete(ev):
     #print('%s completed!', str(ev.job))
     sch.print_jobs()


 sch.add_listener(job_complete, apscheduler.events.EVENT_JOB_EXECUTED)
 sch.start()
 print("Schedule started.")
 sch.print_jobs()

0 个答案:

没有答案