Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz.NET trigger not firing

i am using Quartz.NET in my ASP.NET web application. i put the following code in a button click handler to make sure that it executes (for testing purposes):

Quartz.ISchedulerFactory factory = new Quartz.Impl.StdSchedulerFactory();
Quartz.IScheduler scheduler = factory.GetScheduler();
Quartz.JobDetail job = new Quartz.JobDetail("job", null, typeof(BackupJob));
Quartz.Trigger trigger = Quartz.TriggerUtils.MakeDailyTrigger(8, 30); // i edit this each time before compilation (for testing purposes)
trigger.StartTimeUtc = Quartz.TriggerUtils.GetEvenSecondDate(DateTime.UtcNow);
trigger.Name = "trigger";
scheduler.ScheduleJob(job, trigger);
scheduler.Start();

here's "BackupJob":

public class BackupJob : IJob
{
    public BackupJob()
    {
    }

    public void Execute(JobExecutionContext context)
    {
        NSG.BackupJobStart();
    }
}

my question: why is "BackupJobStart()" not firing? i've used similar code before and it worked fine.

EDIT: @Andy White, i would have it in Application_Start in Global.asax. this doesn't work which is why i moved it to a button click handler to narrow down the problem.


1 Answers

Do you have the Quartz.NET logging hooked up? I once had a problem with a job not executing (I forget why), but once I got the Quartz.NET logging going, the problem was obvious.

It's worth a try (if you're not already doing it):

  • https://www.quartz-scheduler.net/documentation/quartz-2.x/quick-start.html
  • http://netcommon.sourceforge.net/
  • http://netcommon.sourceforge.net/documentation.html

Update: Simply add this to your program.cs to enable console logging:

Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter { Level = Common.Logging.LogLevel.Info};
like image 129
Andy White Avatar answered Oct 26 '25 19:10

Andy White



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!