Job was triggered but code execution never happened

Hi. On my production environment, I have two cron jobs, one will trigger daily and another one monthly.

The thing is for daily job, it was indeed triggered. But all steps in that method never executes. It seems rather weird particularly when monthly was working fine (triggered and method executed) but not for daily(triggered but no method executed). It becomes weirder when the daily job is working as intended when I manually run the job.

Below is how I implemented the code in my startup.cs:

RecurringJob.AddOrUpdate(e=> e.BillEmailsJob(), Cron.Monthly, TimeZoneInfo.Local);
RecurringJob.AddOrUpdate(f=> f.StorageRecord(), Cron.Daily, TimeZoneInfo.Local);

Is there anything that I overlooked?

Bit of a needle and haystack situation but … one thing that pops to mind instantly is … What queue is each of the jobs assigned to (and also check that in the job detail screen of the dashboard to confirm it is actually what you expect it to be).

Reason why I say that is because requeueing a job (depending on your code) does have typically the side effect (unless you have coded something to specifically compensate for this) of changing the queue of said job to DEFAULT. Hence my suggestion of checking what queue the scheduled runs get sent to. And if there is a worker picking up jobs from that queue because if not then it will indeed never actually run.

Cheers,
Hans

This was exactly that was happening to me and for my case I did not assign the BackgroundJobServerOption.Queues value set. I had used a custom queue name in my case but if you are not specifying it you need to set it BackgroundJobServerOption.Queues to “default”.

_server = new BackgroundJobServer(new BackgroundJobServerOptions
{
WorkerCount = Environment.ProcessorCount * 5,
Queues = new[]
{
“default”
}
});