1

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.

3 Answers 3

2

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.

1

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
1

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.

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.