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

So I want to run a timer job only on weekdays. Does anybody have any experience with a similar requirement?

I can think of two options:

  1. Inherit from the SPSchedule class, and write my own custom schedule class.
  2. Use the SPSchedule.FromString() method to read a custom schedule from a string. But I am not sure if I will be able to get exactly what I want from this. The only "documentation" that I have found regarding this function is here

What would be the best way to go about this?

share|improve this question
create 5 weekly schedules..... – Jorris Jun 3 at 20:48

You have to have SPJobDefinition file and the feature file to do this.

 public class ABCTimerJob : SPJobDefinition

        public static string ABCTimerJobName = "ABC timer Job";

        public ABCTimerJob ()

            : base()
            this.Title = TimerJobName ;

        public ABCTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)

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

        public ABCTimerJob(string jobName, SPWebApplication webApplication)

            : base(jobName, webApplication, null, SPJobLockType.ContentDatabase)

            this.Title = TimerJobName ;


        public override void Execute(Guid contentDbId)

            if (DateTime.Today.DayOfWeek != DayOfWeek.Saturday && DateTime.Today.DayOfWeek != DayOfWeek.Sunday)

             //your code here 


In feature activation event you have to do the follwing

        ABCTimerJob abcTimerJob = new ABCTimerJob(ABCTimerJob.ABCTimerJobName, site.WebApplication);
        SPDailySchedule schedule = new SPDailySchedule();
        schedule.BeginHour= 1;
        schedule.EndHour = 1;

        abcTimerJobTimerJob.Schedule = schedule;
share|improve this answer
Was thinking of this solution Sujeewa :)! – Muhammedh Jul 14 '15 at 11:24

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.