I have scheduled the job with particular time interval through apex using 'System.schedule()' method. Now i want to identify, what is the time interval of scheduled job?

For example: if i scheduled jobs with '15 minute' time interval. -> Here, 4 jobs will scheduled with 15 min time interval. then how can i find the time interval of two different scheduled job.

I want to use this time interval in another task. Please help me.

Thank in advance.

More information:

I have used this 'CronTrigger' object already.

  • If there are more than one jobs are scheduled then by using 'StartTime' of tow different jobs, we can identify the time interval of scheduled job.

For example, if jobs scheduled for '15 min' time interval then there are 4 jobs are scheduled. like,

String sch15 = '0 15 * * * ?';          
System.schedule(' Sync 15 Min', sch15, c);              
String sch30 = '0 30 * * * ?';                  
System.schedule(' Sync 30 Min', sch30, c);
String sch45 = '0 45 * * * ?';                  
System.schedule(' Sync 45 Min', sch45, c);
String sch00 = '0 00 * * * ?';                  
System.schedule(' Sync 0 Min', sch00, c);

Then by using CronTrigger object,

List<CronTrigger> listCronTrigger = [select Id, CronExpression, EndTime, NextFireTime, OwnerId, PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey 
  from CronTrigger where State = 'Waiting' or State='Running' or state ='acquired'];
DateTime t1 =   listCronTrigger[0].NextFireTime;
DateTime t1 =   listCronTrigger[1].NextFireTime;
Long l1 = t1.minute();
Long l2 = t2.minute();
Long result = l2 - l1;

Here we get the time interval in 'result'.

  • But if there is only one job schedule for, let say every 2 hour, then only one job scheduled.

for example:

String sch00 = '0 0 1,3,5,7,9,13,15,17,19,21,23 * * ?'; 
System.schedule(' Sync 2 Hour', sch00, c);

In this case i unable to find the time interval.

  • Take a look at salesforce.com/developer/docs/api/Content/… Jan 13, 2015 at 13:14
  • harish - move all these comments into the OP - it is very hard to follow you
    – cropredy
    Jan 14, 2015 at 2:51
  • You might need to restate your question as to why you need to do this and how generalized the solution needs to be as there could be many outstanding async scheduled jobs so it isn't clear which jobs you are trying to interrogate
    – cropredy
    Jan 20, 2015 at 0:03

1 Answer 1


You can see the difference of PreviousFireTime and NextFireTime to get the frequency of the job. if the difference is more than 60 min then it can be assumed as single job.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .