25
Jan

Just a tip for anyone who may be working on a SharePoint Timer job, this could save you a lot of hassle and head scratching…

I have been recently working on a simple enough Timer job. The timer job runs once a day and checks a date field for every item within a list.

if the checked items date is the same as the current date, a notification email is sent to the user who owns / created the item. As I said, simple.

Unfortunately I found out the Timer job runs twice in quick succession instead of once. I thought I must have activated it twice in the code, but after much debugging I found that It had only been deployed and activated once.

Eventually I found that the problem was being caused by a property called SPJobLockType.

This property defines how the instance of a timer job runs.

The value set in the timer job was SPJobLockType.ContentDatabase. This value causes the timer job to be run once for every content database on the farm. We have 2 content databases on the farm, therefore the job was running twice.

I changed the value to SPJobLockType.Job. This locks the job and doesn’t allow it to run more than once on a server and solved my problem.

VN:F [1.9.2_1090]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.2_1090]
Rating: 0 (from 0 votes)

Comments are closed.

-->