2

I have a situation where I need to move some huge data using a timer job. But I can't do this using OneTimeSchedule as it may impact the performance of my sharepoint application during the peak hours.

I want to make it run for maximum of 5 hours a day starting at 20:00 everyday.

What is the best way?

2 Answers 2

1

@sebastienlevert - That will just mean that the job starts sometime between 8pm and 1am

You cannot tell the timer service to terminate execution of a given timer job at a certain time they just run until they have finished.

Timer jobs are designed to be small functions (that is why there are so many of them), it is not intended to be a tool for running long processes.

Could your code be moved to another SharePoint server and run through windows scheduled tasks? Alternatively you could set the timer service to restart at a specific time thus killing off all timer jobs (not advised!)

1
  • If @Faisal codes a SharePoint Job, that would check itself for its total duration? Looping through the process while it has not spent its 5 hours? Would that be a solution that could be use? Oct 7, 2010 at 21:03
0

I think the following snippet of code should do the trick :

SPDailySchedule JobSchedule = new SPDailySchedule();
JobSchedule.BeginHour = 20;
JobSchedule.BeginMinute = 00;
JobSchedule.EndMinute = 00;
JobSchedule.EndHour = 1;

What do you think ?

1
  • 1
    This won't work see my answer. Oct 7, 2010 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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