SharePoint Timer Jobs Running Multiple Times

I was recently brought into a client to help troubleshoot an issue with a SharePoint Timer Job, that appeared to be executing multiple times (around the same time) although it was scheduled to run only once daily. While others in the SharePoint community appeared to experience the same problem, no one seemed to be able to point to a cause.. much less a solution. In this case it was always running 9 times, significantly more than the three or four others where reporting.

After much digging around, and focusing on the magic number (why 9) it struck me. How many Content Databases did the client have on the web application that the Timer Job was associated with? 9 to be exact. It was doing what it needed to do based on how it had been developed, the developers failed to test it on a Web Application with more than one Content Database. From there on, fixing the code was simple.. but it may be different for you based on what your timer job needs to do. Remember every Site Collection (SPSite) has a property that gives you the Content Database, and every time a Timer Job is called (targeting a Content Database) the Content Database GUID for which it is running is passed in… use it for validation.

Anyhow, at the very least, if you are running into this problem this might help point you in the right direction.

For information on how to develop SharePoint Timer Jobs (SPJobDefinition) see Andrew Connells MSDN Article “Creating Custom Timer Jobs in Windows SharePoint Services 3.0”

digg_url = “http://blog.rafelo.com/2009/04/sharepoint-timer-jobs-running-multiple.html”;digg_title = “SharePoint Timer Jobs Running Multiple Times”;digg_bgcolor = “#FFFFFF”;digg_skin = “compact”;digg_url = undefined;digg_title = undefined;digg_bgcolor = undefined;digg_skin = undefined;
Advertisement

4 Comments on “SharePoint Timer Jobs Running Multiple Times”

  1. Clemens says:

    I just found:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spjoblocktype.aspx

    you should use SPJobLockType.Job instead of SPJobLockType.ContentDatabaseJob in the Jobs constructor.

    SPJobLockType.ContentDatabaseJob executes for every DB, the other only once per mashine

    Regards


Leave a Reply

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

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

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

Facebook photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.