Tuesday, July 17, 2007

Starting a SharePoint Timer Job manually

During 2 days we had the SharePoint environment down due a transaction log too large. The root problem was the recycle bin. We threw a process that updated all the files on the site with the unlimited versioning enabled in its Document Libraries. The process executed each 5 minutes and every execution duplicated the info in the site as an old version of each document. After take off-line the database, detach it and attach it again without the transaction log (see the post that explain it) we could recover the space necessary to work. Then we delete each old version of the documents and send it to recycle bin. After set the quarentine period to 1 day we did not want to wait 1 day to get the space free. For that reason, we made this simple code to execute the SPJob that actually deletes the files in the database when it has been deleted of the second level recycle bin.

SPSite site = new

foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)


if (job.Name == "job-recycle-bin-cleanup")






The guid that ypu have to pass is the guid of the content database. I retrieve right clicking on the content database in the central administration (remember to substitute the hex code of the hyphens '-'). In this example the guid retrieved was: DatabaseId=%7BC864BB7F%2D7346%2D4538%2D9720%2D2AADB2ED5247%7D

Related Links:

No comments:

Online Visitors