cancel
Showing results for 
Search instead for 
Did you mean: 

SQL to alert on hung jobs

Chris_Auer_2
Level 4
With 12.5 I have had an issue with jobs getting stuck after the client beremote.exe crashes. Then my job stalls and does not progress onto the next server. I usually have to catch these manually, but I wrote some SQL that will detect them and email me.

Here is the SQL and attached is a C# console app that will generate an email. Just schedule the job every 30 or so minutes and let it run.

SELECT

JobName, [LastChangeDate], DATEDIFF(hh, [LastChangeDate], DATEADD(hh,5,getdate()))

FROM

[BEDB].[dbo].[Jobs]

WHERE

CurrentStatus = 16

AND


DATEDIFF(hh, [LastChangeDate], DATEADD(hh,5,getdate())) > 1
0 REPLIES 0