If the event was scheduled via the UI, you should be able to get the information you want via SOQL. Here's the problem:
CronTrigger has most of the data points you need, which you can access through
CronJobDetail if you query on
Name, which you can see. But the only way to determine which
ApexClass is scheduled is via
AsyncApexJob, which has no relationship to either
An unofficial source claims that the
CreatedDate should match if the job was scheduled through the UI. So if that is the case, you should be able to get the data with two queries. The following worked for me in
Execute Anonymous to infer the necessary data:
CronTrigger jobData = [
SELECT CreatedDate, CronExpression, EndTime
FROM CronTrigger WHERE CronJobDetail.Name = 'Job I Want To Delete'
AsyncApexJob execution = [
SELECT ApexClass.Name FROM AsyncApexJob
WHERE CreatedDate = :jobData.CreatedDate
From there, you can use
System.schedule, though it may get you or someone else into a deeper conundrum down the road.
Schedulable instance = (Schedulable)Type.forName(execution.ApexClass.Name).newInstance();
system.schedule('Job No Longer Deleted', jobData.CronExpression, instance);
However, it may be preferable to simply interpret the
CronExpression for yourself and still schedule through the UI. For example, if you scheduled it to execute at 1:00 PM each weekday, it would look like:
0 0 13 ? * 2,3,4,5,6. If it's scheduled through the UI in the first place, then you will get the hour from the third component, and the days of the week from the final component.
1 indicates Sunday,
2 indicates Monday, etc.