Timer Job on Sharepoint

There are some Job Type schedule that we can put in on our coding on Job Definition, here as below the Job Type :

1.SPMinuteSchedule (ex. every 15 Minute job will running)

SPMinuteSchedule schedule = new SPMinuteSchedule ();
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
schedule.Interval = 15;
job.Schedule = schedule;

2. SPDailySchedule (ex. every 11:00 PM job will running)

SPDailySchedule Schedule = new SPDailySchedule();
Schedule.BeginHour = 23;
Schedule.BeginMinute=0;
Schedule.BeginSecond = 0;
Schedule.EndSecond = 15;
Schedule.EndMinute = 5;
Schedule.EndHour = 23;
Job.Schedule = schedule;
Job.Update();

3. SPMonthlySchedule (ex. every 1 st month will running between 1:15am to 1:30am)

SPMonthlySchedule schedule = new SPMonthlySchedule();
schedule.BeginDay = 1;
schedule.EndDay = 1;
schedule.BeginHour = 1;
schedule.EndHour = 1;
schedule.BeginMinute = 15;
schedule.EndMinute = 30;
Job.Schedule = schedule;
Job.Update();

4. SPWeeklySchedule (Ex. Every monday job will running start from 1:01 AM to 2 :01 Am)

SPWeeklySchedule schedule = new SPWeeklySchedule();
schedule.BeginDayOfWeek = DayOfWeek.Monday;
schedule.BeginHour = 1;
schedule.BeginMinute = 1;
schedule.BeginSecond = 0;
schedule.EndSecond = 5;
schedule.EndMinute = 1;
schedule.EndHour = 2;
schedule.EndDayOfWeek = DayOfWeek.Monday;
Job.Schedule = schedule;
Job.Update();

5. SPYearlySchedule (every Jan 23 at 9:05AM job will running)

SPYearlySchedule Schedule = new SPYearlySchedule();
Schedule.BeginMonth = 1;
Schedule.EndMonth = 1;
Schedule.BeginDay = 23;
Schedule.EndDay = 23;
Schedule.BeginHour = 9;
Schedule.EndHour = 9;
Schedule.BeginMinute = 5;
Schedule.EndMinute = 5;
Schedule.BeginSecond = 0;
Schedule.EndSecond = 5;
Job.Schedule = schedule;
Job.Update();

Happy Sharepoint-ing

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.