Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

@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!)

share|improve this answer
    
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? –  Sébastien Levert Oct 7 '10 at 21:03

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 ?

share|improve this answer
1  
This won't work see my answer. –  Charles Lee Oct 7 '10 at 16:08

Your Answer

 
discard

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.