October 2008 Entries

SharePoint Timer Service and custom jobs

When deploying custom SPOneTimeSchedule job definitions sometimes the timer service (OWSTIMER.EXE) just sorta sits there. Your job definition is created, but isn't executed. It will most likely eventually run, but I have better things to do than sit around wait for it. Setting the time for the job in the past seems to move things along faster. // Create new job CustomJob MyJob = new CustomJob(Constants.JOB_NAME, webApp, properties.Definition.DisplayName); MyJob.Title = Constants.JOB_TITLE; // Set up the job to run once MyJob.Schedule = new SPOneTimeSchedule(DateTime.Now.AddHours(-4)); MyJob.Update();