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

Is there a way to check for the status of a timer job, I need to know the last time it executed and its status, that it run correctly?

share|improve this question
    
This issue has been answered previously. [see this post][1] [1]: stackoverflow.com/questions/12120672/… –  Rahil Jan Muhammad Aug 29 '12 at 2:56
add comment

2 Answers 2

up vote 1 down vote accepted

You could try something like this:

SPWebApplication w = GetYourSPWebApplicationFromSomewhere();
foreach( var e in w.JobDefinitions["YourJobName"].HistoryEntries)
{
    var jobStatus = e.Status;
    var startTime = e.StartTime;
    // TODO: Do your stuff with Status and StartTime
}

var sc = SPFarm.Local.Services;
foreach (var e in sc["YourServiceName"].JobHistoryEntries)
{
    var jobStatus = e.Status;
    var startTime = e.StartTime;
    // TODO: Do your stuff with Status and StartTime
}
share|improve this answer
add comment

SPWebApplication.JobHistoryEntries

SPService.JobHistoryEntries

share|improve this answer
    
example of working code you have? –  L.V. Sharepoint Architect Mar 30 '12 at 13:11
add comment

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.