Activity › Forums › Salesforce® Discussions › How to run a scheduled job every 15 mins?
Tagged: Salesforce Jobs
-
How to run a scheduled job every 15 mins?
Posted by Suraj on April 26, 2017 at 12:25 PMHow to run a scheduled job every 15 minutes?
Кристина Жанько replied 8 years, 9 months ago 3 Members · 2 Replies -
2 Replies
-
Hi Suraj,
You can write a Batch Class and then Schedule it with the help of a scheduler.Let me explain it to you with the help of an example:
BATCH CLASS :
global class test_BATCH implements Database.Batchable<sObject> {
global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext BC) {String query = ‘SELECT Id,Name FROM Account’;
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> scope) {
for(Account a : scope){
a.Name = a.Name + ‘Updated’;
}
update scope;
}
global void finish(Database.BatchableContext BC) {
}
}SCHEDULABLE CLASS :
global class scheduledBatchable implements Schedulable{
global void execute(SchedulableContext sc) {test_BATCH b = new test_BATCH();
//Parameters of ExecuteBatch(context,BatchSize) database.executebatch(b,10);}
}
***Note: if batch size is not mentioned it is 200 by default.
CUSTOM TIMING
String time = ‘0 0 * * * ?’;SheduledBatchable sch = new scheduledBatchable();
system.schedule(‘Hourly Example Batch Schedule job’, time, sch);
*****If you want to run it as frequent as 15,30 or N mins …..
String time = ‘0 15 * * * ?’ ;String time = ‘0 30 * * * ?’ ;
Thanks.
- [adinserter block='9']
-
Our company has a ready-made solution for you! We developed package, that can execute your schedule periodically, like you want. You can configure run time every 5 minutes, every hour, once a month, etc. Available on AppExchange for free: https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000DqCmYUAV
Log In to reply.