Scheduled Batch Class Stuck / Remain in Queued Status in Salesforce Apex Jobs

A scheduled Batch Apex job may show as “Queued” in AsyncApexJob — here’s why and how to verify it’s actually running using CronTrigger and best practices when scheduling.

Overview

Recently, a Batch Apex job scheduled to run daily appeared to be stuck because AsyncApexJob showed the status as “Queued.” This article explains why scheduled apex jobs can show as “Queued,” how Salesforce treats indefinitely scheduled jobs, and how you can confirm execution using the CronTrigger object.

Check the Batch Job in Apex Jobs

To inspect the Apex job details, run the following SOQL against AsyncApexJob to view class, status, errors and dates:

SELECT ApexClassId,
       ApexClass.Name,
       Id,
       JobItemsProcessed,
       JobType,
       Status,
       NumberOfErrors,
       MethodName,
       CreatedDate,
       CompletedDate
FROM AsyncApexJob
WHERE ApexClass.Name = 'Your_Batch_Class_Name'

Why the Status May Stay “Queued”

By design, scheduled apex jobs without an end date are treated as continuously scheduled. Salesforce represents such jobs in AsyncApexJob with a “Queued” status until the job completes or has a defined end date. This can create the false impression the job is stuck.

  • If you schedule a job indefinitely (no end date), AsyncApexJob will show the job as “Queued.”
  • To avoid confusion, always set both a Start Date and an End Date when creating scheduled batch jobs.

How to Verify Execution with CronTrigger

Instead of relying only on AsyncApexJob, query CronTrigger to confirm when the scheduled job runs and whether it has run for a given day:

SELECT FIELDS(ALL)
FROM CronTrigger
WHERE CronJobDetail.Name = 'Your_Batch_Class_Name'

Fields returned include the next scheduled time, previous run time, and the schedule’s daily end time for that execution. This lets you verify the job is executing as expected.

Best Practices

  • Always provide both Start Date and End Date for scheduled jobs to avoid ambiguous “Queued” state.
  • Use CronTrigger for schedule validation and AsyncApexJob for runtime/errors monitoring.
  • Log meaningful execution details in your batch execute/finish methods so you can trace runs using custom logs or platform events.

Conclusion

Understanding how Salesforce represents scheduled jobs prevents hours of unnecessary debugging. Query CronTrigger to confirm schedule execution and set explicit start/end dates when scheduling Batch Apex. These small changes save time for administrators and developers managing scheduled batch processes.

Why this matters: Salesforce admins and developers will be able to quickly distinguish truly stuck jobs from expected “Queued” entries, reducing operational overhead and improving reliability of scheduled automation.