none
Check SpJobDefinition is still running RRS feed

  • Question

  • Hello,

     I have a create a timer job in sharepoint .

    I want to write code if this timer job is still executing or finished . How Can i Implement that ?


    ASk

    Monday, October 8, 2012 7:30 AM

Answers

  • Hi,

    You can write a powershell script or a console application for this.

    Console app :

    You can check the status of the timer job via
    yourwebapplication.JobDefinitions["YourJobName"].HistoryEntries
    OR 
    yourwebapplication.RunningJobs
    OR 
    yourwebapplication.JobHistoryEntries

    You can create a webapplication instance via 

    SPWebApplication oWebApplication = SPWebApplication.Lookup(new Uri("http://MyServer:989"));

    Powershell Script:

    1. Click SharePoint 2010 Management Shell.

    2. To view the history of a specific timer job, type the following command, and then press ENTER:

      (Get-SPTimerJob [-Identity <Timer job name…>]).HistoryEntries | Format-Table -Property Status,StartTime,EndTime,ErrorMessage


    Priyanka

    Monday, October 8, 2012 7:51 AM