Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Although we can delete a running timer job from Central administration Monitoring section, but is there anything that we need to implement in a custom timer job so that the job stops as soon as it is deleted from Central Administration or PowerShell cmdlet?

Because, when i delete the running custom job (one time job) from Central Administration, the job continues to run although Central Administration shows that its no more there.

I thought that I might need to override the Delete() method of SPJobDefinition in my custom job, set a volatile bool flag in it and use this flag in Execute() method to find whether the job is deleted or not. In case it is deleted, this method should exit without processing further items. But for some reason, I ain't getting the updated value of this volatile bool flag in the execute method even though the delete method is called and I verified it in debug mode.

Stuck.

share|improve this question

3 Answers 3

If you need to stop currently runing job you can only use SPPausableJobDefinition with TimerJobUtility class (exapmle from MVP in russian).

If you deleted your job and it still executing by the schedule, then you have some errors with job deleting and you didn't delete your job.

share|improve this answer

Did you make sure to perform these steps?

  1. Deactivate the feature, which actually provisions the custom SharePoint Timer job.
  2. Reset the timer job service
share|improve this answer

TimerJob executes in Owstimer service and central admin executes in w3p processes. Both are different processes. Thats why Delete() method in your job did not get called because its in the other process.

Do do this, you have to persist a flag somewhere(database or cache whatever physibal) and read that flag from owstimer in your job. or you have to write a event which get fired in owstimer service.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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