Get execution times for all jobs
This script retrieves scheduled execution times for all jobs on the server.
The script calls GetJobExecutionTimes to calculate the scheduled executions for all jobs on the server for the next 24 hours.
//if the adTempus server is on a different computer, replace "." with the name
using (var session = Scheduler.Connect(".", LoginAuthenticationType.Windows, "", ""))
{
using (var context = session.NewDataContext())
{
var parms=new JobQueryParameters();
//don't look at held jobs
parms.IncludeHeldJobs= IncludeExcludeType.Exclude;
//specify the jobs or groups to get runtimes for.
//If you add WellKnownOIDs.RootGroup, you tell it to look at all jobs on the server.
//you can also specify the OIDs of one or more individual jobs or groups.
parms.TargetObjects.Add(WellKnownOIDs.RootGroup);
//set the date/time as appropriate; this will get all executions for the next 24 hours
//Note: startTime and endTime must be in the local timezone of the adTempus server
var startTime=DateTime.Now;
var endTime=startTime.AddHours(24);
var runtimes=context.GetJobExecutionTimes(parms, startTime, endTime);
foreach(var item in runtimes)
{
Console.WriteLine(item.FullyQualifiedJobName);
foreach(var runtime in item.ExecutionTimes)
{
Console.WriteLine(runtime.ToString("yyyy-MM-dd HH:mm"));
}
}
}
}