Custom Timer Job in SharePoint 2010


In this article we will be seeing how to create a custom timer job in SharePoint 2010 using Visual Studio 2010. A timer job runs in a specific Windows service for SharePoint Server and performs infrastructure tasks for the Timer service, such as clearing the timer job history and recycling the Timer service; and tasks for Web applications, such as sending e-mail alerts. A timer job contains a definition of the service to run and specifies how frequently the service is started. The SharePoint 2010 Timer service (SPTimerv4) runs timer jobs.

In this article we will be performing the following steps

  1. Creating a custom timer job.

  2. Deploying the timer job.

  3. Registering the timer job

  4. Managing configuration data for timer jobs.

Solution Overview: 

I have a web application => Site Collection =>3 Subsites as shown in the above diagram. Each subsite has a custom list – "Projects" which has the following columns and values

LN subsite:

Java subsite:

SharePoint subsite:

"Test" site collection has a list called "Completed Projects" which will have all the completed projects from all the subsites as shown in the following.

Custom Timer Job:

A SharePoint 2010 timer job can be associated with either a SharePoint Web application or a SharePoint service application. In this example, the timer job class is named "CompletedProjectsJob" and targets the Web application scope. To create a custom timer job do the following steps:

Steps Involved:

  • Open Visual Studio 2010.

  • Go to File => New => Project.

  • Select "Empty SharePoint Project" template from the installed templates.

  • In the "SharePoint Customization Wizard" enter the local site url for debugging and select "Deploy as a farm solution".

  • Right click on the solution and click on "Add new item".Select "Class" template from the installed templates and enter the name as "CompletedProjectsJob.cs".