Created
September 17, 2021 04:32
-
-
Save victorabraham/834f3eac25f49989e4fbc1d12c608da4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This can be any time in future | |
Datetime nextRun = System.now().addHours(2); | |
//Generating cron expression for next run time | |
String year = String.valueOf(nextRun.year()); | |
String day = String.valueOf(nextRun.day()); | |
String hour = String.valueOf(nextRun.hour()); | |
String min = String.valueOf(nextRun.minute()); | |
String sec = String.valueOf(nextRun.second()); | |
String cronExp = sec + ' ' + min + ' ' + hour + ' '+day+' '+nextRun.format('MMM').toUpperCase()+' ? '+year; | |
//Scheduling at the specified time | |
TrackerSchedulable trackerJob = new TrackerSchedulable(); | |
System.schedule('Tracker Job', cronExp, trackerJob); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment