SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have developed a custom timer job, inheriting from SPJobDefinition. It currently runs on two content databases, and I would like it to run on only one.

I have created this timer job using the following constructor:

public HiddenTitleJob(string jobName, SPWebApplication webApplication) :
    base(jobName, webApplication, null, SPJobLockType.Job)
    this.Title = "Hidden Title Timer Job";

Many web sources, including this question, seem to suggest that SPJobLockType.Job prevents my timer job from running on more than one content database, but it hasn't worked for me. Microsoft's documentation is very vague, it only says "Locks the job to prevent it from running on more than one machine" - it says nothing about content databases.

share|improve this question
up vote 2 down vote accepted

This can only be done by adding code to the Execute method of your timer job, like so:

public override void Execute(Guid contentDbId)
    SPSite siteCollection = new SPSite(mySiteCollectionUrl);
    if (siteCollection.ContentDatabase.Id.Equals(contentDbId))
        // timer job code

Neither of the three SPJobLockTypes prevent it from running on all content databases for a single web application.

share|improve this answer
actually i cant remember why i thought SPJobLockType.Job would ever run more than once... I will be using SPJobLockType.Job without the above code until i notice it running more than once, or someone else can clarify – Nacht Jan 9 '13 at 4:46

try using

share|improve this answer
no, that's what it was originally. that SPJobLock runs the timer job over each content database. – Nacht Oct 18 '12 at 10:14

Your Answer


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.