3

I need to kill a job that is surfacing back from a: Sitecore.Jobs.JobManager.GetJobs

I can see it after I've copy/paste this resource in a "Jobs.aspx" :

https://briancaos.wordpress.com/2014/11/11/sitecore-job-viewer-see-what-sitecore-is-doing-behind-your-back/

But how do I GET RID OF IT? Where I right-click the corresponding Windows Server 'Scheduled Tasks' and select "End all instances of this Task" it is followed by no effect.

I see a deprecated Sitecore.Jobs.JobManager.removeJob(Handle handle) in John West's article. Beyond this, the desert or read-only stuff showing the jobs (already good).

I thought it could be a flag in the Sitecore back-end database tables, but found nothing.

Someone's help much appreciated..

3
  • Do you want to stop the job from running in the future or just kill it while it is already running?
    – Richard Seal
    May 5, 2017 at 21:31
  • THank you for you quick answer! Just kill the running one. In the meantime we restarted IIS applications pool and it cleared it, but we need a less invasive solution for the case it's happening again. May 5, 2017 at 22:01
  • The only way I know to kill a running job is to recycle the app pool - the RemoveJob method, only removes the job handle - it doesn't kill the process.
    – Richard Seal
    May 6, 2017 at 3:19

1 Answer 1

4

You can use next code to stop a Sitecore job :

            Sitecore.Jobs.Job job = Sitecore.Jobs.JobManager.GetJob("yourjobname");
            if (job != null)
            {    
                job.Status.State = Sitecore.Jobs.JobState.Finished;
                job.Status.Expiry = DateTime.Now.AddMinutes(-1.0);
            }

I used jobviewer from your link and I stopped few jobs and in jobview appear like on above picture enter image description here

1
  • Thank you Climber, now I'm trying to enhance Jobs.aspx by pasting your code snippet and attempting divers syntaxes, recouping elements found there and there but so far no success (not familiar with .aspx).
    – JRG
    May 8, 2017 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.