Posts

Showing posts with the label How to run a scheduled job every 15 mins?

How to run a scheduled job every 15 mins?

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 * * * ?'...