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

Below is our server topology

3 WFEs 2 App Servers 1 DB server

Now, I would like to write a custom timer job that should run only on the specific application server("APP1").

SPJobdefinition does not allow me to do this as there is no lock type for server.

Shall I use the SPServerJobDefinition class to do this? If so, any sample code would help.

share|improve this question
hi community, any help? – Karthikeyan Nov 7 '12 at 10:25
up vote 0 down vote accepted
namespace DotnetFinder
    class myTimerJobDef : SPServerJobDefinition
        public myTimerJobDef()

            : base()


        public myTimerJobDef(string jobName, SPServer server)

            : base(jobName, server)
            this.Title = jobName;

        public override void Execute(SPJobState _jobState)

            Logs.LogMessage(Logs.Log_INFO, Logs.Log_severity_verbose, "Timer Job - Server specific is running on ");

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
            DotnetFinder.myTimerJobDef myJob = new DotnetFinder.myTimerJobDef("Server Timer Job", SPFarm.Local.Servers["myServer"]);
            // here you can assign the schedule as per your requirement. I have created a daily schedule

            SPDailySchedule schedule = new SPDailySchedule(); // create a daily schedule to run the timer job
            schedule.BeginHour = 1;
            schedule.EndHour = 2;

            myJob.Schedule = schedule;
            myJob.Update(); // assign the schedule to the timer job
share|improve this answer

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.