Recently I came across a requirement in which a batch class was made to run for every 5 minuites though this cannot be fullfilled using a scheduler class to make the batch class run every 5 minuites
//Setting the scheduled time String CRON_EXP1 = '0 5 * * * ?' ; String CRON_EXP2 = '0 10 * * * ?' ; String CRON_EXP3 = '0 15 * * * ?' ; String CRON_EXP4 = '0 20 * * * ?' ; String CRON_EXP5 = '0 25 * * * ?' ; String CRON_EXP6 = '0 30 * * * ?' ; String CRON_EXP7 = '0 35 * * * ?' ; String CRON_EXP8 = '0 40 * * * ?' ; String CRON_EXP9 = '0 45 * * * ?' ; String CRON_EXP10 = '0 50 * * * ?' ; String CRON_EXP11 = '0 55 * * * ?' ; String CRON_EXP0 = '0 0 * * * ?' ; //Batch class variable scheduledBatchClassToInsertAllLists bt1 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt2 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt3 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt4 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt5 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt6 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt7 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt8 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt9 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt10 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt11 = new scheduledBatchClassToInsertAllLists(); scheduledBatchClassToInsertAllLists bt0 = new scheduledBatchClassToInsertAllLists(); //Scheduling the batch class for the specific time System.schedule('Hourly Batch Schedule job1', CRON_EXP1, bt1); System.schedule('Hourly Batch Schedule job2', CRON_EXP2, bt2); System.schedule('Hourly Batch Schedule job3', CRON_EXP3, bt3); System.schedule('Hourly Batch Schedule job4', CRON_EXP4, bt4); System.schedule('Hourly Batch Schedule job5', CRON_EXP5, bt5); System.schedule('Hourly Batch Schedule job6', CRON_EXP6, bt6); System.schedule('Hourly Batch Schedule job7', CRON_EXP7, bt7); System.schedule('Hourly Batch Schedule job8', CRON_EXP8, bt8); System.schedule('Hourly Batch Schedule job9', CRON_EXP9, bt9); System.schedule('Hourly Batch Schedule job10', CRON_EXP10, bt10); System.schedule('Hourly Batch Schedule job11', CRON_EXP11, bt11); System.schedule('Hourly Batch Schedule job0', CRON_EXP0, bt0);This will run the scheduled batch class for every 5 minutes till infinity !
No comments:
Post a Comment