{"id":770,"date":"2013-02-12T12:40:14","date_gmt":"2013-02-12T12:40:14","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=770"},"modified":"2024-05-06T12:19:20","modified_gmt":"2024-05-06T12:19:20","slug":"sharepoint-timer-job-history-analysis","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/analyzing-timer-history\/","title":{"rendered":"SharePoint Timer Job History analysis"},"content":{"rendered":"<h4>Analyzing the SharePoint Timer Job History<\/h4>\n<p>At times one needs to analyze the timer job history to see what jobs have ran a long time. The Central Admin user interface limits you to a sequential view, although you can filter by Service or Web Application. The actual timer job history is maintained in a single table in the Config DB. Here\u2019s a simple SQL Select to get the 100 longest running timer jobs in a time range:<\/p>\n<p>&nbsp;<\/p>\n<pre lang=\"php\">\/****** Script for SelectTopNRows command from SSMS  ******\/\r\nSELECT top 100 [Id]\r\n      --,[ServiceId]\r\n      --,[WebApplicationId]\r\n      --,[JobId]\r\n      --,[ServerId]\r\n      ,[Status]\r\n      ,[StartTime]\r\n      ,[EndTime]\r\n      ,[WebApplicationName]\r\n      ,[JobTitle]\r\n      ,[ServerName]\r\n      ,[DatabaseName]\r\n      ,[ErrorMessage]\r\n      ,datediff(S,StartTime,EndTime) as SecondsElapsed\r\n  FROM [SharePoint_2013_Farm].[dbo].[TimerJobHistory]\r\n  where StartTime &gt; '2013-02-12 02:40:00' and EndTime &lt; '2013-02-12 03:55:00'\r\n  --note that the TimerHistory timestamp is always in GMT!\r\n  order by SecondsElapsed desc\r\n<\/pre>\n<pre lang=\"php\">$events= Invoke-SQLcmd -Server \"NY-SRV-SQLPRD02\" -Database SharePoint_2013_Farm \"select  JobTitle,WebApplicationName,ServerName,DatabaseName, StartTime,EndTime,ErrorMessage from dbo.TimerJobHistory where Status=3 and StartTime between GETDATE() -1 and GETDATE()\" \r\n<\/pre>\n<p>Then in PowerShell:<\/p>\n<pre lang=\"php\">foreach($event_num in $event) \r\n{ \r\n \r\n Invoke-SQLcmd -Server \"NY-SRV-SQLPRD04\" -Database MYdbreports \"insert into [SharePoint].[TimerJobHistory]  ( Status,StartTime,EndTime,JobTitle,ServerName,DatabaseName,ErrorMessage ) values ($event_num.Status,$event_num.StartTime,$event_num.EndTime,$event_num.JobTitle,$event_num.ServerName,$event_num.DatabaseName,$event_num.ErrorMessage)\"\r\n  \r\n }<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Analyzing the SharePoint Timer Job History At times one needs to analyze the timer job history to see what jobs have ran a long time. The Central Admin user interface limits you to a sequential view, although you can filter by Service or Web Application. The actual timer job history is maintained in a single [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":929,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[35],"tags":[],"class_list":["post-770","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=770"}],"version-history":[{"count":1,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/770\/revisions"}],"predecessor-version":[{"id":781,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/770\/revisions\/781"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/929"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}