我有一份工作,我想每十分钟运行一次。为了安排它,我使用:
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!");
}
起初它似乎工作,工作每十分钟运行一次。但是,大约一个小时后,它停止运行。我记录成功和错误,我没有错误。是什么导致我的工作自行停止?
我正在使用 GoDaddy 的共享主机计划运行 IIS 7、.NET Framework 4.0。