Salesforce Developers Salesforce Consultants Salesforce Salesforce Developers

HELLO|WELCOME TO CLOUD HELP|A SALESFORCE SOLUTION|WE LOVE TO DO CREATIVE THINGS|SALESFORCE CONSULTANTS FROM INDIA

How to schedule batch class after every 4 hours in a day



















You can use the System.schedule method, which takes a cron string to represent the repeating time.

Key is to create string expression that will result in firing every two hours:
Something like:

0 0 1,3,5,7,9,13,15,17,19,21,23 * * ?

Key is to create string expression that will result in firing every four hours:
Something like:

0 0 0,4,8,12,16,20 * * ?

So you can create expression to run batch on specific hours as in above example!

Go to dev console and execute code like below, this code will schedule batch for every four hours.

String CRON_EXP = '0 0 0,4,8,12,16,20 * * ?';
testScheduler sch = new testScheduler();
system.schedule('Update job', CRON_EXP, sch);

Share this:

CONVERSATION

1 comments:

Navneet kumar, Software consultant from delhi, India. Basically from Bisfi, Madhubani Bihar. Software Engineer!

Navneet kumar bisfi madhubani bihar

Navneet bisfi madhubani bihar

Nabu Nabbu bisfi madhubani bihar

Navneet Software consultant from delhi

Navneet kumar Software consultant from delhi

Navneet kumar Software Engineer bisfi madhubani bihar

Nabu Nabbu Software Engineer bisfi madhubani bihar

bisfi madhubani bihar

Salesforce

Salesforce Consultant

Salesforce Developer

Salesforce Best Blog

Salesforce Cloud Computing

Cloud Computing

Salesforce Customizations

Salesforce Developments

Apex Salesforce

Apex Controllers

Salesforce Triggers, classes, work flows