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
Bryan Leaman 6Bryan Leaman 6 

Scheduled apex class did not run

I've scheduled a handful of Apex classes to run daily functions after normal business hours. They have been running just fine for over a year. But recently (last month or so), sometimes the first job in the sequence doesn't run.  It shows that it was submitted on the scheduled job list, but never appears in the list of Apex jobs that started and ran.

This is NOT an issue of the job failing or aborting. Even if that happens, there's an entry in the list of Apex jobs showing that status. In my case, it seems that once or twice a week the Scheduled job list will show that the job was submitted, but it never shows up in batch and does not run.

Any thoughts? I tried calling salesforce support because it sounds like a platform issue in the scheduler, but we have to have developer support for them to look into why their job scheduler is failing. And developer support is too expensive. I've tried adjusting the start time, but so far that hasn't helped.

Scheduler says it started

Did not start
 
Best Answer chosen by Bryan Leaman 6
Bryan Leaman 6Bryan Leaman 6
Our account manager got me a small amount of developer support to look at the internal salesforce logs and found that a query in the class constructor was timing out, so the job never started even though the scheduler logged it as having started.  I don't usually place large queries in a constructor and was able to move this one into the start method, which runs under batch limits. I also found that while date fields are automatically indexed, it seems that CreatedDate is indexed more efficiently. So I limited the data I was considering by created date as well and the SOQL query runs more efficiently now.

All Answers

SwethaSwetha (Salesforce Developers) 
HI Bryan,
Batch jobs are asynchronous in nature and so the system will process the batches only when the system resources are available. There's no way to prioritize a process, and SLA for the execution cannot be provided.

You can check the Apex flex queue to verify your job status. When system resources become available, the jobs are taken from the top of the Apex flex queue and moved to the batch job queue. Up to five queued or active jobs can be processed simultaneously for each org.

Also, consider checking trust.salesforce.com and verify if there has been any downtime on your Salesforce instance which at times might affect the asynchronous processes.


Related : https://help.salesforce.com/articleView?id=000330214&type=1&mode=1
 
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Bryan Leaman 6Bryan Leaman 6
Our account manager got me a small amount of developer support to look at the internal salesforce logs and found that a query in the class constructor was timing out, so the job never started even though the scheduler logged it as having started.  I don't usually place large queries in a constructor and was able to move this one into the start method, which runs under batch limits. I also found that while date fields are automatically indexed, it seems that CreatedDate is indexed more efficiently. So I limited the data I was considering by created date as well and the SOQL query runs more efficiently now.
This was selected as the best answer