Hi I am trying to unschedule the sling jobs(Scheduled jobs) in aem 6.1 programmatically.
Its not working. I am using below method.
public void stopScheduledJob() {
Collection<ScheduledJobInfo> myJobs = jobManager.getScheduledJobs(TOPIC, 10, null); myJobs.foreach(sji -> sji.unschedule());
}
Please let me know, is there any other solution apart from this.
PS: I dont want to delete manually under /var/eventing/scheduled-jobs
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @KaustubaTM ,
You can try finding job using
Job |
getJob(java.lang.String topic, java.util.Map<java.lang.String,java.lang.Object> template)
Find a job - either queued or active.
|
Once you have job, you can get the Job id from that job
java.lang.String |
getId()
Unique job ID.
|
Then stop or remove that job using job id
void |
stopJobById(java.lang.String jobId)
Stop a job.
|
boolean |
removeJobById(java.lang.String jobId)
Removes the job even if it is currently in processing.
|
hi @KaustubaTM , If you are using any cron expression to schedule your sling job then you can try changing cron expression to unschedule it.
Hi Nikita,
I am using below method to schedule. if I change the cron param, it will create a new job with new time
ScheduleBuilder scheduleBuilder = jobManager.createJob(TOPIC).schedule();
scheduleBuilder.daily(21, 00);
Hi @KaustubaTM ,
You can try finding job using
Job |
getJob(java.lang.String topic, java.util.Map<java.lang.String,java.lang.Object> template)
Find a job - either queued or active.
|
Once you have job, you can get the Job id from that job
java.lang.String |
getId()
Unique job ID.
|
Then stop or remove that job using job id
void |
stopJobById(java.lang.String jobId)
Stop a job.
|
boolean |
removeJobById(java.lang.String jobId)
Removes the job even if it is currently in processing.
|
Views
Like
Replies