How to Schedule an Apex Class to run every 30 minutes?

12:45 PM


Execute 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

  1. String cronStr = '0 30 * * * ?';
    for 30th minute

    ReplyDelete
  2. The second part of the code should be as follows:

    ClassName gp = new ClassName();
    String cronStr = '0 30 * * * ?';
    System.schedule('Job which runs at every 30th minute of hour', cronStr, gp);

    ReplyDelete
  3. Thank you both for correcting. I have updated the same.

    ReplyDelete

Stats