1

I want to create a custom timer job with a SPYearlySchedule. The job deploys successfully, but when I view its settings in the central admin, it is shown to have an hourly schedule: enter image description here

Furthermore, as you can see, there seems to be no way to manually configure the job as a yearly job - SharePoint only lists radio boxes ranging from "Minutes" to "Monthly" and that's it.

What could be the cause of this? Here's how I'm creating the schedule:

private void CreateJob(SPWebApplication webApp)
{
    MyTimerJob job = new MyTimerJob(MyTimerJob.TimerJobName, webApp);
    SPYearlySchedule schedule = new SPYearlySchedule();
    schedule.BeginMonth = 10;            
    schedule.BeginDay = 10;            
    schedule.BeginHour = 1;            
    schedule.BeginMinute = 0;            
    schedule.BeginSecond = 0;
    schedule.EndMonth = 10;
    schedule.EndDay = 15;
    schedule.EndHour = 3;
    schedule.EndMinute = 0;
    schedule.EndSecond = 0;
    job.Schedule = schedule;
    job.Update();
}

I can create other schedules (e.g. weekly or daily) without any problems.

3 Answers 3

4

As far as i understand your query, because there is no UI(User interface) for yearly job in Central administration, that's why it is showing like this. But if you go to Scheduled Jobs page, it will show the correct next time. As it will be scheduled between 10th to 15th October this year.

That might be little issue with the UI. You can check it is scheduled properly.

Hope this helps!!!

5
  • Looks like this is it, the job is actually scheduled as yearly, but SharePoint for some reason has no UI that would show it as such - a bug, looks like.
    – w128
    Commented Sep 3, 2014 at 12:47
  • Yes.. Because there is no UI. Job is scheduled on time. Do mark this as answer. It it resolves your issue.
    – Aanchal
    Commented Sep 3, 2014 at 12:55
  • Thanks, I will mark it shortly. I guess there is no fix for this bug?
    – w128
    Commented Sep 3, 2014 at 12:58
  • I don't think it would be a bug. Its Just UI issue. As functionalist is working fine. May be in next versions they will provide UI for yearly schedule as well.
    – Aanchal
    Commented Sep 3, 2014 at 13:00
  • Well, it's a bug since it means that users cannot configure custom yearly schedules ... Kind of annoying but oh well, that's SharePoint. :)
    – w128
    Commented Sep 3, 2014 at 13:02
0

I don't see issue with your code here. Just to rule out dll issue, after you deploy your code and before activating timer feature, try to restart SharePoint timer service. This will reload updated assembly. Also, there is one codeplex utility called SharePoint Timer Job Administration available. I have been using it to manage timer jobs. It is very handy tool in this situation. It was made for SP2007 but it is compatible with SP2010 as well.

1
  • Thank you. I always restart the timer service, but it doesn't change the result - yearly schedule doesn't work, other schedules work normally instantly. I unfortunately cannot rely on 3rd party utilities because my timer jobs needs to be deployable to other environments where such utilities may be absent.
    – w128
    Commented Sep 3, 2014 at 11:56
0

try to fill all data for schedule object as follows:

private void CreateJob(SPWebApplication webApp)
{
    MyTimerJob job = new MyTimerJob(MyTimerJob.TimerJobName, webApp);
    SPYearlySchedule schedule = new SPYearlySchedule();
    schedule.BeginMonth = 10;            
    schedule.BeginDay = 10;            
    schedule.BeginHour = 1;            
    schedule.BeginMinute = 0;            
    schedule.BeginSecond = 0;
    schedule.EndMonth = 10;
    schedule.EndDay = 15;
    schedule.EndHour = 3;
    schedule.EndMinute = 59;
    schedule.EndSecond = 59;
    job.Schedule = schedule;
    job.Update();
}

Setting the BeginHour, BeginMinute, and BeginSecond without specifying the EndHour, EndMinute, and EndSecond values will prevent the timer job from running.

Hope it helps,

Andrew

1
  • Unfortunately, no difference.
    – w128
    Commented Sep 3, 2014 at 12:24

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.