function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

FYI - Stopping a Scheduled Job when the UI won't let you (unable to delete scheduled process)

I ran into a problem last week when I was putting the finishing touches on a Schedulable Apex class, and I thought I'd pass the information along.  For those of you familiar with CronTrigger and System.abortJob(), you need not read further.


I had scheduled the job to run in the sandbox, and since the Client was also doing some testing I wanted to have as little downtime as possible while I made my updates.  My class names were fine, but I thought that the scheduled job's name could be more descriptive.  I deleted the job, saved my class changes and re-scheduled the job, unfortunately including an illegal/invalid character (' > ', in this case) in the job name.  The schedule took and the processing was fine, but when I tried to make a subsequent change to the class I couldn't delete the job!


Instead, I was getting an error related to 'page unavailable' and what appeared to be a reference to the job name having too many characters.


The upshot was that neither the Manage nor Delete links worked for the Scheduled Job, which meant that I could not save my changes because the batch was still running. It was time to delve into CronTrigger to delete the process from under the hood.


Using the schema query tool we were able to identify the job that was running (there was only one, and we could compare to the name listed under 'Monitoring / Scheduled Jobs')



Select c.State, c.StartTime, c.NextFireTime, c.Id, c.CronExpression, c.CreatedDate From CronTrigger c where ownerid = '<your user id, presumably>'

 With the Id from our query, we could then run



 and delete the process.



Just remember, Don' Panic (and always carry a towel.)




Imran MohammedImran Mohammed

Nice info.

Edwin KEdwin K



I've used system.abortJob method to stop the schedule process but it doesn't work.. The job is still visible in my Scheduled Jobs.. I can't delete it because the job name is too long.. I need to delete it so I can update my apex code, need help on this.. How do you guys can do system.abortJob method?