Quartz.NET網(wǎng)站定時任務(wù) 每周凌晨1點(diǎn)更新無法執(zhí)行,如何解決?
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
Global.asax 代碼:
IScheduler sched; private void Application_Start( object sender, EventArgs e) { ISchedulerFactory sf = new StdSchedulerFactory(); IScheduler sched = sf.GetScheduler(); IJobDetail job = JobBuilder.Create<TimingTask>().WithIdentity( "sport_quan_job" , "sport_quan_group" ).Build(); ITrigger trigger = TriggerBuilder.Create().WithIdentity( "sport_quan_job" , "sport_quan_group" ).WithCronSchedule(PubConfig.CronExpr).Build(); sched.ScheduleJob(job, trigger); sched.Start(); LogHelper.WriteLog( "Application_Start" , "Application_Start" ); } private void Application_End( object sender, EventArgs e) { LogHelper.WriteLog( "Application_End" , "Application_End" ); // 在應(yīng)用程序關(guān)閉時運(yùn)行的代碼 if (sched != null ) { sched.Shutdown( true ); } } TimingTask.cs 實(shí)現(xiàn)接口IJob: public void Execute(IJobExecutionContext context) { try { if (System.DateTime.Now.Hour == 1) { DataSet dsArrange = new stadium_arrange().SelectArrangeList(); long result = ArrangeHelper.InsertScheduleOfField(dsArrange); if (result > 0) { LogHelper.WriteLog( "更新排班" , "定時更新排班成功!" ); } else { LogHelper.WriteLog( "更新排班" , "暫無更新!" ); } } else { LogHelper.WriteLog( "定時任務(wù)" , "僅執(zhí)行定時任務(wù),不作更新排班操作!" ); } } catch (Exception ex) { LogHelper.WriteLog( "程序異常" , ex.Message); JobExecutionException e2 = new JobExecutionException(ex); // this job will refire immediately e2.RefireImmediately = true ; throw e2; } } web.config 配置:
<!--Quartz[0 0 1 * * ?] 配置項(xiàng) 每天凌晨1點(diǎn)更新--> <add key="cronExpr" value="0 0 1 * * ?"/> 這兩天執(zhí)行的日志如下: 2014年9月17日_log.txt 標(biāo)題: Application_Start 內(nèi)容: Application_Start 時間: 2014/9/17 19:30:38 --------------------------------------------- 標(biāo)題: Application_Start 內(nèi)容: Application_Start 時間: 2014/9/17 20:52:03 --------------------------------------------- 標(biāo)題: Application_End 內(nèi)容: Application_End 時間: 2014/9/17 21:08:02 --------------------------------------------- 標(biāo)題: Application_Start 內(nèi)容: Application_Start 時間: 2014/9/17 22:02:32 --------------------------------------------- 標(biāo)題: Application_End 內(nèi)容: Application_End 時間: 2014/9/17 22:23:32 --------------------------------------------- 2014年9月18日_log.txt 標(biāo)題: Application_Start 內(nèi)容: Application_Start 時間: 2014/9/18 4:25:39 --------------------------------------------- 標(biāo)題: Application_End 內(nèi)容: Application_End 時間: 2014/9/18 4:38:39 --------------------------------------------- 標(biāo)題: Application_Start 內(nèi)容: Application_Start 時間: 2014/9/18 9:05:39 --------------------------------------------- 問題來了,即沒有執(zhí)行凌晨一點(diǎn)的定時任務(wù),而且中間還隔了幾個小時未記錄任務(wù)日志,求各位大神支招!!! 該文章在 2021/3/8 12:26:21 編輯過
|
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |