You need to sign in to do that
Don't have an account?
Dinesh Pathak
How to schedule class in Apex
I want to schedule a class for every 5 min.
how to implement this.
how to implement this.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Greetings!
You can do this even from a single Scheduled Job.
In your class.
1. Before execution of your code, fetch the current job from CRONTRIGGER.
2. Abort the job System.abortJob(cronId).
3. Now, Schedule the new job for after 5 min.
4. Execute your schedule class code.
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi
All Answers
Let’s say your batch class name is BatchApexIllustration.
System.schedule('Schedule Job Now', '0 00 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 1', '0 5 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 2', '0 10 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 3', '0 15 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 4', '0 20 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 5', '0 25 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 6', '0 30 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 7', '0 35 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 8', '0 40 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 9', '0 45 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 10', '0 50 * * * ?', new BatchApexIllustration());
System.schedule('Schedule Job after 5 minutes - 11', '0 55 * * * ?', new BatchApexIllustration());
In the above code we have used what is called the CRON expression - example '0 5 * * * ?'. To understand more on Apex Scheduler and the expression, refer this: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
Greetings!
You can do this even from a single Scheduled Job.
In your class.
1. Before execution of your code, fetch the current job from CRONTRIGGER.
2. Abort the job System.abortJob(cronId).
3. Now, Schedule the new job for after 5 min.
4. Execute your schedule class code.
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi
Please refer this link
https://howtodoitinsalesforce.blogspot.com/2016/12/run-schedule-class-in-every-5-mins-in.html
Thanks!