The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to Automate to kill long running jobs.

GaneshkumaB0736
Mega Contributor

Hello,

 

I would like to know if anyone implemented.  the Automation to kill the long running jobs.

If anyone done. please guide or can you provide script idea to implement.

 

Thanks in advance.

2 REPLIES 2

YaswanthKurre
Giga Guru

Hi @GaneshkumaB0736 ,

 

We can implement this using a schedule job that runs periodically (e.g., every 5 minutes).

This job will:

  1. Query the sys_trigger table to find all currently running jobs.

  2. Check the run time of each job against a predefined threshold (e.g., 60 minutes).

  3. If a job exceeds the threshold, it will be terminated.

NOTE: Automatically killing long-running jobs can unintentionally stop legitimate processes that require extended execution time. To prevent disrupting important workflows or flows, it is critical to apply strict and precise criteria when targeting jobs for termination.

 

Mark this as helpful and correct if this helps.

 

Thanks,

Yaswanth

 

 

KrishnaMohan
Giga Sage

@GaneshkumaB0736 

 

 There's no single "OOB" feature for this, Improperly killing a job could lead to data corruption or incomplete transactions and ServiceNow recommends manual intervention and fixing the root cause of the long-running job. Improving the performance of a transaction is always the best practice.


Before implement automation, is this real value to your business  and why you are implementing.

 

May this article useful for you Avoiding time-consuming transactions being automatically cancelled 

 

 

If this helped to answer your query, please mark it helpful & accept the solution.
Thanks!
Krishnamohan