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
GeekyAkshayGeekyAkshay 

How to check if scheduled job is expired or not ?

We have scheduled a job year a go, and it might have expired now, but we are unsure about it, how to check if its still running or expired ?
Already tried with CronTrigger object !
Parmanand PathakParmanand Pathak

Hi,
Goto Setup---> Scheduled Jobs where you can see Next Scheduled Run.

User-added image

Thanks,
Parmanand Pathak

GeekyAkshayGeekyAkshay
Hi Parmanand, 

Thanks for the reply, but i wanted to see the expired scheduled jobs. Schedules Job section not displaying expired jobs.

Thanks
Raj VakatiRaj Vakati
You cant able to directly get in one SOQL query 



EndTime is the field on the  one which you need to check the crontrigger 

Use this code to get the details
 
List<CronTrigger> cTrigger =[Select Id ,EndTime,StartTime ,CronJobDetail.Name From CronTrigger];

Set<Id> jobIdsThatAreExpired = new Set<Id>();
For(CronTrigger c : cTrigger){
    if(c.EndTime<System.today()){
        System.debug('Expired Jobs'+c.Id);
        jobIdsThatAreExpired.add(c.Id);
    }
}