locked
How to stop the running instance of the Share point Timer job RRS feed

  • Question

  • hi all,

    i have a requirement to provide an option to manage (stop and Start) the custom timer jobs.

    so i am creating instance of the the exisiting timer job class and scheduling it for the Current time stamp using the spchedule.

    When the user clicks on the "Stop" . i am deleting the timer job from the jobdefinition collection.

    The Problem: the instance is internally running and not stoping as required.

    Please provide me an solution in this business scenario.

    Note : i am implementing the whole stuff in the Web part with start and stop button options.

    Thanks,

    keshav.

     

     

     

     

     

     

     

    • Edited by Mike Walsh FIN Thursday, July 8, 2010 4:43 AM Moderator Note: Under no circumstances is it justified to bump a post after 20 minutes. (I have deleted that completely unnecessary bump post). Wait at least 2-3 *days* before bumping and even then give more information.
    Wednesday, July 7, 2010 2:03 PM

Answers

  • Refer to the related post...

    "when you register a timer job, it creates a timer job definition. as long as timer job definition stays in, Sharepoint will kick off the job based on its definition which is for example every 5 minute or once in a day etc. So if your requirement is to cancel a job, you will need to delete the timer job definition. However if timer job has started executing, you can not really STOP it unless you reset IIS or stop Sharepoint Windows Timer Service. so programmatically you can control the cancellation of a job in advance before that scheduled time reaches but you can not really control the other thing which is to stop an executing job. and restarting WSS timer service is not a good idea to acheive the second part."

      http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/4b4e2284-48df-4fca-9760-7178646cf90d



    My Blog
    http://dhireny.blogspot.com
    • Marked as answer by Wayne Fan Monday, July 12, 2010 8:31 AM
    Wednesday, July 7, 2010 2:15 PM

All replies

  • Refer to the related post...

    "when you register a timer job, it creates a timer job definition. as long as timer job definition stays in, Sharepoint will kick off the job based on its definition which is for example every 5 minute or once in a day etc. So if your requirement is to cancel a job, you will need to delete the timer job definition. However if timer job has started executing, you can not really STOP it unless you reset IIS or stop Sharepoint Windows Timer Service. so programmatically you can control the cancellation of a job in advance before that scheduled time reaches but you can not really control the other thing which is to stop an executing job. and restarting WSS timer service is not a good idea to acheive the second part."

      http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/4b4e2284-48df-4fca-9760-7178646cf90d



    My Blog
    http://dhireny.blogspot.com
    • Marked as answer by Wayne Fan Monday, July 12, 2010 8:31 AM
    Wednesday, July 7, 2010 2:15 PM
  • Probably u can disable the timer job when not needed and again enable the timer job and make it to execute immidiately.

    Use the following properties of SPJobDefinition:

    IsDisabled Gets or sets whether the job definition should be disabled.
    SPJobDefinition.IsDisabled = true on Stop button click

    Then on Start button click:

    SPJobDefinition.IsDisabled = false.

    and then SPJobDefinition.RunNow(). - Which will execute timer job immidiately.

    Hope this helps. 


    Thanks & Regards
    Rakesh Narayan Lal
    Wednesday, July 7, 2010 4:57 PM
  • Wednesday, July 7, 2010 5:04 PM