4

I have a 2 timerjobs which both have SPJobLockType set to SPJobLockType.Job to ensure they only run on 1 server and they run once every hour.

However they seem to be running twice with only 1 minutes difference. But the funny thing is that they do so for 4-5 hours and then for 2-3 hours they only run once as they are supposed to and then again 4-5 hours where they both run twice.

So my logs looks like this:

TimerJob1 - Executed: 02-04-2014 02:59 AM
TimerJob1 - Executed: 02-04-2014 03:00 AM

TimerJob2 - Executed: 02-04-2014 02:59 AM
TimerJob2 - Executed: 02-04-2014 03:00 AM

I've checked the code. There is no logic in them that makes them trigger twice.

Any ideas?

2
  • 1
    Any solution for this? I am running into same problem.
    – user40238
    Commented Mar 5, 2015 at 12:27
  • @Puvi I found that it was because the timerjob was set to run at 59 minutes and there seem to be a bug when the timer is so close to top of the hour. I solved this by putting the run at 55 minutes instead and the "error" disappeared.
    – user2536
    Commented Mar 5, 2015 at 18:12

2 Answers 2

1
public override void Execute(Guid contentDbId)
{
...
 SPSite site = webApplication.Sites["sites/dev"];
if (site.ContentDatabase.Id.Equals(contentDbId))
{
... // put your code here and it will only run once for the targeted site collection.
}
...
}
1

I found that it was because the timerjob was set to run at 59 minutes and there seem to be a bug when the timer is so close to top of the hour. I solved this by putting the run at 55 minutes instead and the "error" disappeared.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.