function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BrianWXBrianWX 

Possible Cron Job Bug

I have a schedule batch apex that execute this line of code:
 
Test.startTest();
String jobId = System.schedule('testSomeBatch', '0 0 13 * * ?', new ProcessScheduledBatch());
Test.stopTest();
From the cron expression, it'd run every day at 1:00 PM.

When I executed my test code and output the cron job, this is what I have:
ct: CronTrigger:{Id=08e2f00000MEbhJAAT, CronExpression=0 0 13 * * ?, TimesTriggered=0, State=WAITING, NextFireTime=2022-10-21 20:00:00}
I would expect it to have next run at 13:00:00 hour, not at 20:00:00 hour.

The cron expression I took directly from Apex Schedule documentation: https://developer.salesforce.com/docs/atlas.en-us.232.0.apexcode.meta/apexcode/apex_scheduler.htm

Did I miss anything?


 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Brain,

In the UI, Go to the scheduled jobs and check with the name of testSomeBatch and what is the next schedule time.?

In your output it was past value 
NextFireTime=2022-10-21 20:00:00

Thanks!!