function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Santi Ram RaiSanti Ram Rai 

System.Schedule method

Hi every body.
This is my System.Schedule method:
updateStatus_interface obj = new updateStatus_interface();
String sch = '0 0 8 * * ?';
System.schedule('New', sch, obj);

Which can Scheduled Next Scheduled Run as this:
User-added image

Now, my question is how to Schedule, which can run every 10 or 12 or 30 minutes?
Best Answer chosen by Santi Ram Rai
Arun KumarArun Kumar
No you need to run all statement like for 10 minutes:
For 10 minutes, please run:
Number of expression:  60/10 = 6


updateStatus_interface obj = new updateStatus_interface(); 
String sch1 = '0 0 * * * ?'; System.schedule('New1', sch1, obj); 
String sch2 = '0 10 * * * ?'; System.schedule('New2', sch2, obj);
String sch3 = '0 20 * * * ?'; System.schedule('New3', sch3, obj); 
String sch4 = '0 30 * * * ?'; System.schedule('New4', sch4, obj);
String sch5 = '0 40 * * * ?'; System.schedule('New6', sch5, obj);
String sch6 = '0 50 * * * ?'; System.schedule('New6', sch6, obj);

All Answers

Arun KumarArun Kumar
Hi Santi,

You need to make x number of exppression like for every 15 minutes x would be = 60/15 i.e 4
 
updateStatus_interface obj = new updateStatus_interface();
String sch1 = '0 0 * * * ?';
System.schedule('New1', sch1, obj);

String sch2 = '0 15 * * * ?';
System.schedule('New2', sch2, obj);

String sch3 = '0 30 * * * ?';
System.schedule('New3', sch3, obj);

String sch4 = '0 45 * * * ?';
System.schedule('New4', sch4, obj);

 
Santi Ram RaiSanti Ram Rai
This above code will run four times only today and stop. But my question is it should run each time in 10 minutes forever.
 
Arun KumarArun Kumar
Hi Santi, 

No if you will execute them than it will be forever for every 15 minutes.

Please try and see.

Thanks,
Arun
Santi Ram RaiSanti Ram Rai
If it is so, then this:
updateStatus_interface obj = new updateStatus_interface();

String sch2 = '0 15 * * * ?';
System.schedule('New2', sch2, obj);
code is enough yes?

 
Arun KumarArun Kumar
No you need to run all statement like for 10 minutes:
For 10 minutes, please run:
Number of expression:  60/10 = 6


updateStatus_interface obj = new updateStatus_interface(); 
String sch1 = '0 0 * * * ?'; System.schedule('New1', sch1, obj); 
String sch2 = '0 10 * * * ?'; System.schedule('New2', sch2, obj);
String sch3 = '0 20 * * * ?'; System.schedule('New3', sch3, obj); 
String sch4 = '0 30 * * * ?'; System.schedule('New4', sch4, obj);
String sch5 = '0 40 * * * ?'; System.schedule('New6', sch5, obj);
String sch6 = '0 50 * * * ?'; System.schedule('New6', sch6, obj);
This was selected as the best answer