[SalesForce] What’s the difference between AsyncApexJob and CronTrigger

Roughly I know that when I schedule a Schedulable, I'm creating both a CronTrigger and an AsyncApexJob, but I'm confused as to how the two objects relate to each other and what the significance of each is.

For example, if I'm looking at all scheduled jobs, I can look at the unfired triggers or filter on status for the async jobs. What are the pros and cons of examining one over examining the other?

Best Answer

CronTrigger is the parent job that will be run; it can have many runs attached to it. AsyncApexJob is a single job, including batchable, queueable, and future methods. So, if you want to know what's coming up, CronTrigger will let you know what's scheduled, while AsyncApexJob shows prior executions. If you want to know what's already run, AsyncApexJob is the the best choice, while if you want to know what's coming up, CronTrigger is the best.