[SalesForce] How to See Scheduled Job Run History

I have a scheduled job that is supposed to run every night at midnight. Recently users have said that the job didn't run; however this is sporadic, some nights it works and others it doesn't.

Is there a way for me to see scheduled job run history? I'm hoping to be able to verify either that it didn't run or that it did run and the code just didn't do what was expected.

Looking at the scheduled jobs page in setup, it appears I can see the last time it ran from the 'Started' column, but I'm looking for a comprehensive list of all the runs so I can verify it either ran or didn't on days the users saw issues.

If not I'm thinking I'll have to wait until the day they notice the issue again and then look at the scheduled jobs page to see if it ran last night or not.

Best Answer

Here is the query I run in workbench, or you can use dev console as well.

SELECT CronJobDetail.Name, cronjobdetail.JobType ,
  CreatedBy.name,CronExpression,EndTime,Id, 
  NextFireTime,PreviousFireTime,StartTime,State, TimesTriggered FROM 
  CronTrigger 
  where cronjobdetail.JobType = '7'
  or cronjobdetail.JobType = '9'
  order by PreviousFireTime desc limit 25

You can get the types on the dev page for CronJobDetail. I was looking for just scheduled apex and batch jobs. This does not give you entire history and I don't know if that is possible but it give a lot of information that may help you answer your question.

https://developer.salesforce.com/docs/atlas.en-us.218.0.api.meta/api/sforce_api_objects_cronjobdetail.htm