How to Schedule an Apex Class to run every 30 minutes?
12:45 PMExecute the following two blocks of code separately from the developer console. The system will create two jobs, one which runs every 0th minute (1PM 2PM 3PM etc) and one which runs every 30th minute (1:30PM 2:30PM 3:30PM etc)
ClassName gp = new ClassName();
String cronStr = '0 0 * * * ?';
System.schedule('Job which runs at every 0th minute of hour', cronStr, gp);
ClassName gp = new ClassName();
String cronStr = '0 30 * * * ?';
System.schedule('Job which runs at every 30th minute of hour', cronStr, gp);
3 comments
String cronStr = '0 30 * * * ?';
ReplyDeletefor 30th minute
The second part of the code should be as follows:
ReplyDeleteClassName gp = new ClassName();
String cronStr = '0 30 * * * ?';
System.schedule('Job which runs at every 30th minute of hour', cronStr, gp);
Thank you both for correcting. I have updated the same.
ReplyDelete