Is there a way to use System.schedule to schedule a job that runs only once? I've been looking at the special characters allowed there, and I'm not seeing a way to do it.

What I want to do is use one scheduled job that runs once a week to spawn five separate run-once jobs that will check for missing attendance on specific days.

If scheduling a job to run-once isn't an option, is it possible to have a scheduled job that runs and kills other scheduled jobs?

1 Answer 1


You can do either option (both are viable).

To specify a run-once schedule, specify a fully qualified date and time, such as:

0 0 0 4 JUL ? 2014
| | | | |   | |
| | | | |   | \------- YEAR (2014)
| | | | |   \--------- DAY_OF_WEEK (NOT_SPECIFIED)
| | | | \------------- MONTH (JULY)
| | | \--------------- DAY_OF_MONTH (4th)
| | \----------------- HOUR (0- MIDNIGHT LOCAL TIME)
| \------------------- MINUTE (0)
\--------------------- SECOND (0)

This would run at midnight of the scheduling user on the Fourth of July this year, and never again.

If you want to kill other jobs, you simply query for scheduled jobs that are not already cancelled, and then call System.abortJob on those ID values. See CronTrigger for more information.

Finally, you can also abort the current job in the execute() method:

public void execute(SchedulableContext sc) {
    // Do stuff here
  • 5
    best ASCII ever... this is great! Sep 30, 2015 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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