Skip to content

Instantly share code, notes, and snippets.

@dcarroll
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcarroll/9610109 to your computer and use it in GitHub Desktop.
Save dcarroll/9610109 to your computer and use it in GitHub Desktop.
global class MyScheduler implements Schedulable {
global void execute(SchedulableContext ctx) {
// The query used by the batch job.
String query = 'SELECT Id,CreatedDate FROM Merchandise__c ' +
'WHERE Id NOT IN (SELECT Merchandise__c FROM Line_Item__c)';
CleanUpRecords c = new CleanUpRecords(query);
Database.executeBatch(c);
}
global static void RunInOneMinute() {
Datetime d = Datetime.now();
d.second();
MyScheduler p = new MyScheduler();
String second = d.second() + ' ',
minute = (d.minute() + 1) + ' ',
hour = d.hour() + ' ',
day = d.day() + ' ',
month = d.month() + ' ',
dayofweek = '? ',
year = d.year() + '';
String sch = second + minute + hour + day + month + dayofweek + year;
System.debug('Schedule: \n' + sch);
system.schedule('One Time Pro', sch, p);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment