Cron job is not triggered

Hi,

I’m trying to add a cron job, but the job is never executed. I’ve tried different cron expressions without any luck.

Here’s my class:

[CronScheduler("Litium.Accelerator.SomeSyncJob", Parameter = "Some=parameter", ExecutionRestriction = ScheduleCronJobExecutionRestriction.None)]
public class SomeSyncJob : ICronScheduleJob
{
    public ValueTask ExecuteAsync(object parameter, CancellationToken cancellationToken = default)
    {
        // Execute the sync job
        return ValueTask.CompletedTask;
    }
}

appsettings.json:

"Litium": {
  "Scheduler": {
    "Policy": {
      "Litium.Auditing.CleanupScheduler": { "CronExpression": "0 45 0 1/1 * ? *" },
      "Litium.Customers.TargetGroups.CleanupScheduler": { "CronExpression": "0 13 0 ? * * *" },
      "Litium.Products.PriceAgentScheduler": { "CronExpression": "0 45 0 ? * * *" },
      "Litium.Sales.OrderMaintenanceScheduler": { "CronExpression": "0 40 0 ? * * *" },
      "Litium.Websites.SitemapScheduler": { "CronExpression": "0 25 0 ? * * *" },
      "Litium.Accelerator.PurchaseHistory": { "CronExpression": "0 30 3 ? * * *" },
      "Litium.Accelerator.SomeSyncJob": {
        "CronExpression": "0 17 16 1/1 * ? *"
      }
    }
  }

The problem here is that the job is never executed. I’ve tried to change the time in the cron expression to one hour before/after, and also added more delay with several minutes to the correct time. Am I missing something?

I’ve also tried with the property DefaultCronExpression, and also tried adding the Parameter property to appsettings.json, same story there.

Litium version: 8.3.1

Did you generate your changes by this page?
And try only with:

[CronScheduler(“Litium.Accelerator.SomeSyncJob”)]

I generated the expression using the link from the docs, which is this one.

I tried the attribute with just the policy name, but made no difference. I also tried to generate the expression from the site you provided, but the task is still not executed…

Edit:
Alright, I tried with this expression: 0 21 * ? * * *, to trigger the job at minute 21 each hour, and the job was executed. I guess there must be some kind of time zone difference between the clock in the accelerator and the clock on my PC?

Confirmed. The expression 0 10 7 ? * * * triggered the job successfully at 09:10, which means the hours are shifted two hours back for cron jobs. At least on my PC. Is this is a bug?

I created a bug report for this, as I’m not sure if this is the intended behaviour or not.

1 Like

Not sure if this is a bug but Product team will decide on that. I believe it must be based on UTC time however.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.