Manually kick a CronJob


I looked into the definition of this type but could not find a start or run like Batch or MapReduce jobs!

How can I manually kick a CronJob?



The whole point of a CronJob is that it is started by a timer… To perform the same action that a CronJob is performing, you can just call the function that the cron job calls.

1 Like


Thanks @rileysiebel indeed I can just call the action executed by the cron job. I was just wondering if there is a way at least for testing to trigger the cron manually, but it seems it does not.



CronJobs can be manually kicked off by invoking the schedule() member function on the CronJob Instance you wish to trigger. This function declares a schedule for the given CronJob to be valid in between the start and end times given. When testing, always put a small time window, because you often don’t want to overwrite any existing schedule. If you put the cronExpression input of the function to null or an empty string, the CronJob will be triggered one time immediately and be processed in the CronQueue as it would if it was triggered in an automated way.


CronJob.get('cron_job_id').schedule({startTime: "2018-04-24", endTime: "2018-04-24T23:00", cronExpression: "", skipOverdue: true})


CronJob.get(‘cron_job_id’).schedule({startTime: “2018-04-24”, endTime: “2018-04-24T23:00”, cronExpression: “”, skipOverdue: true})

This seems to modify the cron expression in scheduleDef, which does not seem to be override by provisioning. So after the cron runs, the expression has to be changed back to the original version.

CronJob.get(‘cron_job_id’).schedule({cronExpression: "0 2 0 1 * ? *", skipOverdue: true})
1 Like