我有一份工作,我想每十分鐘運行一次。要安排它,我使用:作業停止運行?
public static IScheduler _scheduler { get; private set; }
...
ISchedulerFactory schedFact = new StdSchedulerFactory();
_scheduler = schedFact.GetScheduler();
_scheduler.Start();
string cron = "0 0/10 * 1/1 * ? *";
JobKey jobkey = new JobKey("Radar", "F");
IJobDetail job = JobBuilder.Create<RadarJob>()
.WithIdentity(jobkey)
.Build();
CronScheduleBuilder csb = CronScheduleBuilder.CronSchedule(new CronExpression(cron)).InTimeZone(TimeZoneInfo.Local);
ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create()
.WithIdentity("Radar-Trigger", "G")
.WithSchedule(csb)
.Build();
try
{
DateTimeOffset ft = _scheduler.ScheduleJob(job, trigger);
Response.Write("Job Scheduled");
}
catch (ObjectAlreadyExistsException)
{
Response.Write("Job Already Exists!");
}
它似乎起初工作,工作每十分鐘運行良好。但是,一小時左右後,它會停止運行。我記錄成功和錯誤,並且我沒有錯誤。什麼導致我的工作自行停止?
我正在運行IIS 7,.NET Framework 4.0,使用GoDaddy中的共享主機計劃。
也許所有的應用程序都停止了,因爲它會長時間閒置嗎?看看這個問題和答案:http://stackoverflow.com/questions/16749021/iis-turned-off-my-application-automatically – Aristos
請參閱[「應該問題包括」標籤「在他們的標題?」](http:///meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles),其中的共識是「不,他們不應該」! –