You need to sign in to do that
Don't have an account?

Unable to abort Recursive batch job
Hello Helpers
by mistake I started recursive batch class chain
In the batch finsih() method I inserted a call for the same batch
Now I have a batc running for half day I can not stop it
Abor does not work If i try to abort I get the be,ow message
Failed to Abort Job Unable to remove job from Apex Job Queue.
I need to stop this somehow
What opton I have?
In the specs I sew that "You can submit up to 5,000 batches per rolling 24 hour period."
but since start my batch run more then 5000 times
regards
csaba
by mistake I started recursive batch class chain
In the batch finsih() method I inserted a call for the same batch
Now I have a batc running for half day I can not stop it
Abor does not work If i try to abort I get the be,ow message
Failed to Abort Job Unable to remove job from Apex Job Queue.
I need to stop this somehow
What opton I have?
In the specs I sew that "You can submit up to 5,000 batches per rolling 24 hour period."
but since start my batch run more then 5000 times
regards
csaba
Get Batch job ID from Setup->Monitoring -> Apex Jobs to get batch job ID.
and Run below statement from Anonymous block.
Let us know if it helps.
Ashish is correct. Please mark this as solved and choose best answer.
Regards,
Santosh Chitalkar
I know this because I am here for the same reason ;)
List<AsyncApexJob> jobs = [SELECT Id, Status FROM AsyncApexJob WHERE Status NOT IN ('Completed', 'Failed')];
for (AsyncApexJob job : jobs)
{
System.abortJob(job.Id);
}
To solve this issue. I've deleted a class called by the job.
So, you have to keep at it until you catfch one one of them.
Basically click Abort on each page refresh, then quickly hit the enter key to confirm - and keep doing this until the page refreshes with the Status 'Aborted' on the top line.
List<AsyncApexJob> jobs = [SELECT Id, Status FROM AsyncApexJob WHERE Status NOT IN ('Completed', 'Failed','Aborted') limit 150];
for (AsyncApexJob job : jobs)
{
System.abortJob(job.Id);
}
Integer count = 20;
while(true) {
count--;
if(count<0) {
break;
}
List<AsyncApexJob> jobs = [SELECT Id, Status FROM AsyncApexJob WHERE Status NOT IN ('Completed', 'Failed','Aborted') limit 150];
for (AsyncApexJob job : jobs)
{
System.abortJob(job.Id);
}
}
Hi Everyone,
The following code worked for me.
List<AsyncApexJob> jobs = [SELECT Id, Status FROM AsyncApexJob WHERE Status NOT IN ('Completed', 'Failed','Aborted') FOR UPDATE];
for (AsyncApexJob job : jobs)
{
System.abortJob(job.Id);
}
The "FOR UPDATE" keyword locks the record,due to which Apex job is not processed.This will allow the Apex Job to terminate even before executing.
Mark it as best solution if this works for you too.
List<CronTrigger> jobs = [Select Id, CronJobDetail.Name, State, NextFireTime From CronTrigger limit 10];
for(CronTrigger job : jobs)
{
System.debug(job);
System.abortJob(job.Id);
}
To do this, you need to login as a different user or ask your colleague to do it for you.