You need to sign in to do that
Don't have an account?
SV M
Stop Batch Class
Hi, I have a batch class which was running continuously form a long time. Can someone tell me how to abort the job? I have tried aborting from Setup -> Apex Jobs but that didn't work. Is there any other way to abort the job. Please tell me if there is any another way...
Thanks in Advance...
Thanks in Advance...
What is the status of the apex job that you are trying to abort?
Can you run the below query and share the result
SELECT Id, CreatedDate,Status FROM AsyncApexJob WHERE JobType='ApexToken' AND Status = 'Queued'
If the above query returns any records then please log a ticket with Salesforce Support to have the apextoken jobs cleared.
If there are no records returned in the above query then follow the below steps:
1. Login to "https://workbench.developerforce.com/login.php"
2. On right corner, it will be showing your name and API version. Click on the link.
3. There you will find change API version, change it to 31
4. Go to Utilities >> Apex Execute and run the command below.
for ( AsyncApexJob aJob : [ Select id ,Status from AsyncApexJob where Status = 'Queued' or Status='holding'] )
{
System.AbortJob(aJob.Id);
}
Reference article: https://help.salesforce.com/articleView?id=000265430&language=en_US&type=1
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful.
Thanks
All Answers
Abort will stop the current execution of the Batch, but your Batch is being executed from a Schedule class, that need to be deleted from Scheduled Jobs.
To abort long running batch, future or scheduled Apex jobs, you may use System.abortJob() from the Developer Console (execute anonymous window) and pass the job id to this method.
Please follow the articles for more information
https://help.salesforce.com/articleView?id=000324656&type=1&mode=1
https://salesforce.stackexchange.com/questions/121630/abort-currently-running-job-in-salesforce
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful.
Thanks
What is the status of the apex job that you are trying to abort?
Can you run the below query and share the result
SELECT Id, CreatedDate,Status FROM AsyncApexJob WHERE JobType='ApexToken' AND Status = 'Queued'
If the above query returns any records then please log a ticket with Salesforce Support to have the apextoken jobs cleared.
If there are no records returned in the above query then follow the below steps:
1. Login to "https://workbench.developerforce.com/login.php"
2. On right corner, it will be showing your name and API version. Click on the link.
3. There you will find change API version, change it to 31
4. Go to Utilities >> Apex Execute and run the command below.
for ( AsyncApexJob aJob : [ Select id ,Status from AsyncApexJob where Status = 'Queued' or Status='holding'] )
{
System.AbortJob(aJob.Id);
}
Reference article: https://help.salesforce.com/articleView?id=000265430&language=en_US&type=1
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful.
Thanks
The method worked and the batch was stopper successfully. Thanks for your help...
7072w00009StBHW this is ApexJob Id
AsyncApexJob ct =
[SELECT Id,ParentJobId,cronTriggerId
FROM AsyncApexJob WHERE Id ='7072w00009StBHW'];
System.abortJob(ct.cronTriggerId);