Introduction
============
Moss relies heavily on timer jobs in a certain number of functional fields. timer jobs run at a fixed time period. However, they always run on a given schedule. what if you want a special timer job to run according to your ideas? This articleArticleWill tell you the answer.
Replace schedule of timer jobs
============
If you want to force a moss timer job, unfortunately, you cannot do this because every timer job has a fixed schedule.
There are three types of Schedule:
Although you cannot force a timer job, you can undoubtedly modify the execution time plan of a timer job, which can help you fulfill your desire to force a timer job. for example, Usage Analysis job is a daily job. it is executed only once a day. if you want this job to be executed immediately, you can change it from "Daily" to "minutes ".
All built-in Moss timer jobs can be modified using the setproperty command of the stsadm command line. to run the Usage Analysis job from 24 hours to 5 minutes, run the following command:
Stsadm-O setproperty-PN job-usage-analysis-PV "every 5 minutes"
The names of all other built-in timer jobs are listed below:
- Job-change-log-Expiration
- Job-dead-site-delete
- Job-diskquota-warning
- Job-immediate-Alerts
- Job-Recycle-bin-cleanup
- Job-usage-Analysis
- Job-Workflow
- Job-workflow-autoclean
- Job-workflow-failover
List of formats with different frequencies
|
Job frequency |
Example time format |
|
Immediate |
"Every 5 minutes between 0 and 59" |
|
Daily |
"Daily between 22:00:00 and 06:00:00"
"Daily between 0:00:00 and 01:00:00" |
|
Weekly |
"Weekly between Fri 22:00:00 and Mon 06:00:00"
"Weekly at SAT 0:00:00" |
if you have a custom timer job definition and want to modify its schedule, the only method that can be thought of is to use the object model. because there is no stsadm command to help you modify Custom jobs. the following is an example of Code . It shows how to modify the schedule of a custom job and change it to the Schedule calculated by minute:
using (spsite site = New spsite (" http: // SERVERNAME " )) { using (spweb = site. openweb () {spfarm farm = site. webapplication. farm; spwebapplication webapp = site. webapplication; foreach (spjobdefinition jobdef in webapp. jobdefinitions) { // If (jobdef. webapplication = sitecollection. webapplication) // console. writeline (jobdef. title); If (jobdef. title = "Usage Analysis" ) {jobdef. schedule = New spminuteschedule (); jobdef. update (); Break ;}}
Conclusion
==============
If you want to execute a moss timer job that will be executed again after a long time, you can modify the schedule of this job. if the job is built in, you can modify it through stsadm. if a job is customized, the only feasible method is to use the moss SDK.
Run the following command to immediately execute the administrative timer jobs
Stsadm-O execadmsvcjobs
Translated from:
Forcing execution of moss timer jobs
Http://blogs.msdn.com/tehnoonr/archive/2009/02/15/forcing-execution-of-moss-timer-jobs.aspx