我有一份工作,我想每十分钟运行一次。要安排它,我使用:作业停止运行?
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),其中的共识是“不,他们不应该”! –