I have a custom timer job in which the scope of the timer job is "Web Application", which is defined in feature of timer job.

Now When i have deployed the timer-job it runs for all the web application in the farm. Is there a way where we can define the scope of this timer-job to a specific web Application .

  • 1
    You can deactivate custom timer job web application feature in your web application. Deploy your solution on particular web application only in the farm. Aug 2, 2017 at 6:50

2 Answers 2


Your scope of timer job is already at Web Application.

So what you have to do is, just make sure the feature should not be auto activated. You just disable the setting Automatically Activate.

So, just activate the feature on the Web Application you need to use.


A job does not have a thing such as a "scope". They have a lock (Job, Database and None) but that's something else.
So you're actually talking about the scope of the feature that deploys (through a feature event receiver).
Several things have to be noted:

  • Web application-scoped features are (by default) automatically activated when the WSP is deployed. That means your feature is activated multiple times, once per content Web application you have in the farm.
  • This means multiple instances of your job may be created (e.g. 2 Web applications -> 2 jobs are created in the list of job definitions).
  • It's up to you to associate the Web application the feature is activated on to the job you're instantiating. This can be done by setting the WebApplication property of the job:

public MyJobDefinition(SPWebApplication webApp) : base(GetJobName(webApp), webApp, null, SPJobLockType.Job) { }

  • Then, in the Execute method, you may access the Web app and enumerate (for instance) its site collections to get the job done on each.
  • You may give a name to your job that reflects the Web app it's associated with.
  • You can deactivate the feature on the Web applications you don't want it: don't forget that add code in the feature ER when the feature deactivates to unregister the job for that Web app.

A good sample can be found at https://msdn.microsoft.com/en-us/library/ff798313.aspx.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.