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

I built a custom Timer Job on activation I was able to debug it and it was going through Execute method I am overriding but suddenly its not overriding anymore.

Code is here:

   public class TimerJob : SPJobDefinition
        private const string TIMERJOB_NAME = "Timer Job";

        public TimerJob()
            : base()

        public TimerJob(SPWebApplication webApp)
            : base(TIMERJOB_NAME, webApp, null, SPJobLockType.ContentDatabase)
            this.Title = TIMERJOB_NAME; 

        public override void Execute(Guid targetInstanceId)
            catch (Exception ex)
                AppCode.Logging.LogWepApplicationErrorMessage(ex, TIMERJOB_NAME, this.WebApplication.Name);

While Debugging it goes through second constructor and ignores Execute method and returns control to Feature Receiver class


I defined schedule as below, but even after 5 minutes when I check Job properties > Last run time: it says N/A

    SPMinuteSchedule schedule = new SPMinuteSchedule();
    schedule.BeginSecond = 0;
    schedule.EndSecond = 120;
    //SPHourlySchedule schedule = new SPHourlySchedule();
    //schedule.BeginMinute = 0;
    //schedule.EndMinute = 3;
    TimerJob.Schedule = schedule;

simply doesn't work :(

share|improve this question
up vote 2 down vote accepted

Unless you're explicitly calling Execute from within your FeatureReceiver then it should't be called at that time.

The Execute method should be called by the timer service when it's running your timer job

Specifying an EndSecond of 120 isn't valid BeginSecond and EndSecond specify where in the minute it should start and no minutes have more that 60 seconds.

And you don't specify how often it should run by setting Interval.

What you meant was probably:

SPMinuteSchedule schedule = new SPMinuteSchedule();
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
schedule.Interval = 2;
TimerJob.Schedule = schedule;  

This specifies run every second minute (anywhere in that minute)

And also remember to recycle the TimerJob Service whenever you update your timerjob.

share|improve this answer
I edited my question – Muhammad Raja Jul 27 '12 at 11:03
true, I am not calling it anywhere it should be called automatically :) – Muhammad Raja Jul 27 '12 at 11:10

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.