I've got the follow code, which is inside my startup.cs class
It is registered as expected, but it also triggers the the method to run. Even though I've specified between 2-3 AM. The job has not yet been finished successfully, with the last 24 hours.
If the job was successfully run, within the last 24 hours, it appears to not run during startup.
How to i stop it from triggering outside the specified hours?
RecurringJob.AddOrUpdate<HangfireMediator>("local-xml-files",
m => m.Send(new ImportFeedFilesCommand() { RunInBackground = false }),
"0 2-3 * * *",
TimeZoneInfo.Local
);
Hi @rasmuseeg,
This is a strange behavior, since I've never seen that happening for years. The AddOrUpdate method just register a recurring job, without execute anything else. I see 2 possible reasons for this behavior:
1 - You have already a HangfireMediator.Send() task enqueued in the database, so when the service starts, it is executed.
2 - You have another piece of code that is expliciting doing a Enqueue() or Schedule() of your method.
If you are able to provide a repository with this problem ocurring, I can try to help you figure it out 馃槃
Kind regards
Hi there,
I'm having the same problem on the latest version. Here's a more or less simple repro:
The same outcome, if the job was created at 16:00, but never executed.
GlobalConfiguration.Configuration.UseSqlServerStorage("***");
var backgroundServerOptions = new BackgroundJobServerOptions
{
ServerName = $"{Environment.MachineName}.{Guid.NewGuid().ToString()}"
};
var server = new BackgroundJobServer(backgroundServerOptions);
RecurringJob.AddOrUpdate("Test", () => Job(), "0 16 * * *", TimeZoneInfo.Local); // change the cron to "0/5 * * * *" at step 3.
Expected result:
The job should be scheduled to the next occurrence of the new cron since now.
Funny I just came to same conclusion yesterday, but you beat me to it here. Thanks! 馃榿
@tukaef, what about previous versions?
any updates on this? I am getting the same issue.
@rsilvanet @odinserj
Any updates on this? Please let me know if you need some extra information.
I just experienced this. Our cron job is scheduled to run Mon-Sat. Our hangfire server was rebooted on Sunday and a task ran which we do not want to run on Sundays.
Most helpful comment
Hi there,
I'm having the same problem on the latest version. Here's a more or less simple repro:
The same outcome, if the job was created at 16:00, but never executed.
Expected result:
The job should be scheduled to the next occurrence of the new cron since now.