I support quite a few third-party applications, many of which install Database Maintenance jobs of their own (e.g. purging, populating, etc.) Once in awhile these jobs interfere with day-to-day activities or my normal DBA maintenance jobs.
The repetitive task of finding the answer to "Why is XXX so slow today?", or "Why is the reindex taking so long this weekend?" usually involves checking to see if these third-party jobs are running/runaway/stuck. Normally, the job is killed by an administrator and life goes on.
Having laid that out, I wanted a way to be alerted or automatically take an action on my behalf so that I could retain my precious Corona time.
The code I provided will either send an Alert to the specified SQL Operator ('Alert'), or stop the job ('Kill') depending on what argument is set. This code can be altered to be placed directly within a "Governer" job, or you can make it into a Stored Procedure on a database of your choosing within the instance and call it for multiple jobs.
Logic can also be added to take other actions of your choosing. Hope you enjoy this as it's saved me quite a bit of time in the past year!