Home > MOSS 2007, SharePoint, SharePoint 2010 > SharePoint – Timer Job Executing Multiple Times

SharePoint – Timer Job Executing Multiple Times

Custom timer jobs are created by inheriting SPJobDefinition class. This class is available under Microsoft.SharePoint.Administration namespace.

Recently I was working on a timer job which was scheduled to run every 5 minutes. After deployment I found the job is invoked multiple times during each 5 minute cycle. In my case this was executing 10 times. This happened because I have 10 content database. To avoid this we should make use of the SPJobLockType enumeration.

public MyCustomTimerJob(string jobName, SPWebApplication webapp) : 
base(jobName, webapp, null, SPJobLockType.Job) {
	this.Title = "My Custom Timer Job";
}

Hope this helps!

Advertisements
  1. Antanas
    December 3, 2014 at 4:20 PM

    Woop, thank you for the solution, this solved my issue!

    I was following one of the Timer Job tutorials on CodeProject, and it had the Job Lock Type set to Content Database for some reason.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: