0

this is my apex class for scheduling to run every 30 min.but when i scheduled in salesforce it will run after one hour but i need to run my scheduled class for every 30 mins.anyone help me to gohead

this is my scheduled class :

global class SchedulingService implements Schedulable {

   global void execute(SchedulableContext SC){


    ServiceNowUpsert.GetIncident('xxxxx','xxxxx','xxxxx');         
       String day = string.valueOf(system.now().day());
      String month = string.valueOf(system.now().month());
      String hour = string.valueOf(system.now().hour());
      String minute = string.valueOf(system.now().minute() + 30);
      String second = string.valueOf(system.now().second());
      String year = string.valueOf(system.now().year());

      String strJobName = 'Job-' + second + '_' + minute + '_' + hour + '_' + day + '_' + month + '_' + year;
      String strSchedule = '0 ' + minute + ' ' + hour + ' ' + day + ' ' + month + ' ?' + ' ' + year;
      System.schedule(strJobName, strSchedule, new SchedulingService());    
   }
}

Thanks

  • 1
    Simply schedule two jobs, thirty minutes apart, as listed in the duplicate question I've linked for you. Suicide scheduling, as it's called, is risky at best. If your scheduler fails even once, your job will hang forever until you restart it. If you just schedule two jobs to run hourly (0 0 0 * * ? and 0 0 30 * * ?) your jobs will always run and never require a manual restart. – sfdcfox Apr 20 '17 at 5:25
-1

Can you please try the below format :

System.schedule('Scheduled Job', '0 30 * * * ?', new ScheduledClass());

| improve this answer | |
  • 1
    That will run it once an hour half past the hour. – sfdcfox Apr 20 '17 at 5:20
  • thanks for giving the reply to all i w'll check and update – Srikar Apr 20 '17 at 5:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.