1

I have developed a Windows service using Quartz.Net . I deployed it on one machine, everything works fine. The trigger is triggered at the right time. But by deploying the same deployment on the second machine, the trigger simply does not work. He registers, the schedule is running, but he does not work out. I don't understand what the problem might be if it works on one machine and not on the other... I've looked at all the possible issues.

Here is the Quartz configuration code:

 {
 try
 {
 var jobFactory = new JobFactory(_serviceProvider);
 _scheduler.JobFactory = jobFactory;
 var triggers = new List<ITrigger>();
 foreach (var location in LocationCronExpression.Keys)
 {
 string cronExpression = LocationCronExpression[location];
 var jobDetail = JobBuilder.Create<CronJob>()
 .WithIdentity($"CronJob_{location}", "DefaultGroup")
 .UsingJobData("Location", location)
 .Build();
 ITrigger trigger = TriggerBuilder.Create()
 .WithIdentity($"Trigger_{location}", "DefaultGroup")
 .WithSchedule(CronScheduleBuilder
 .CronSchedule(cronExpression)
 .InTimeZone(TimeZoneInfo.Local)) 
 .ForJob(jobDetail)
 .Build();
 
 await _scheduler.ScheduleJob(jobDetail, trigger);
 triggers.Add(trigger);
 ServiceLogger.Log.Debug($"Зарегистрирован триггер: {trigger.Key.Name} для тегов с location4 = {location}");
 }
 ServiceLogger.Log.Debug("Триггеры зарегистрированы.");
 await _scheduler.Start();
 }
 ServiceLogger.Log.Debug($"Quartz запущен. {_scheduler.IsStarted}");
 foreach(var trigger in triggers)
 {
 DateTimeOffset? nextFireTime = trigger.GetNextFireTimeUtc();
 if (nextFireTime.HasValue)
 {
 ServiceLogger.Log.Debug($"Следующее выполнение триггера {trigger.Key.Name} для {trigger.JobKey.Name}: {nextFireTime.Value.DateTime}");
 }
 else
 {
 ServiceLogger.Log.Debug("Триггер не запланирован на выполнение");
 }
 }
 ServiceLogger.Log.Debug($"Scheduler shutdown??? {_scheduler.IsShutdown}");
 }
 catch (Exception ex)
 {
 ServiceLogger.Log.Fatal("Ошибка при создании расписания запуска службы: " + ex);
 return;
 }
 }
asked Mar 4, 2025 at 10:11
4
  • Can you be a little specific about what is reached. it looks like you log everything and the code seems fine. What is it running as? console app, iis? Commented Mar 4, 2025 at 11:28
  • why cant you use the built in windows scheduling. or if you are in linux, use cron. and then invoke your script or console app from there. Commented Mar 4, 2025 at 13:42
  • @ThomasKoelle This is a Windows service. I have two servers in a cluster (it needs to work in fault tolerant mode). The servers are identical, I installed the service using InstallUtil on the same server. Everything is working successfully, triggers are triggered when I need them, jobs are executed. Then I decided to install on the second server. All the steps are successfully completed, the triggers are registered, the schedule is started, but when it's time for the trigger to fire, nothing happens. Commented Mar 4, 2025 at 14:07
  • The job doesn't even start executing. I've already tried all the options, the builds are identical, and the settings are the same. What can block the execution of triggers? I added so many logs because I was trying to figure out where the error was happening. But there are no errors in this part of the code. If everything is working on one server, but not on the other, then I do not know what it is. Commented Mar 4, 2025 at 14:07

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.