Cancel a backgroupnd_progress_worker

Jeff Booth
Kilo Guru

Good afternoon - a couple weeks ago I triggered a fix script, then cancelled it. I went to the Transactions - All Nodes view and verified it no longer showed as running.

 

Today I was sifting through the event log and noticed my log statement from that script has been generating empty logs since that day. I pulled up the xmlstats.do listing and searched for backround_progress_workers and found my script has been running since 2 weeks ago. I still do not see it in the transactions log and it still shows cancelled on that particular progress worker under the fix script. 

Suggestions on how I can terminate the script? 

1 ACCEPTED SOLUTION

Jeff Booth
Kilo Guru

NOW Support provided this article: KB0635968 - How to Cancel a Long Running Transaction <-- it worked, the transaction is no longer running. 

-Just searched for the transaction under System Diagnostics > Active Transactions (All Nodes), tight-click and select 'Kill'

-The job may linger for a while (I checked back after 3 hours and it was gone). 

 

View solution in original post

5 REPLIES 5

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Jeff Booth ,

 

Apologies for the confusion. If the script is running in a background process, you might need to consider a different approach to handle this situation. Here's what you can do:

 

### 1. **Identify the Running Script:**

   - Use the "System Definition" > "Background Scripts" module to identify the script that is running indefinitely.

 

### 2. **Check GlideSystem Threads:**

   - Use the `GlideSystem` object in a script to check the running threads. For example, you can use the `GlideSystem.getThreadInfo()` method to get information about the running threads.

   - Run a script that checks the running threads and looks for your script. If found, you can attempt to stop it.

 

   Example Script to Check Threads:

 

   var threadInfo = gs.getThreadInfo();

   var threads = threadInfo.getThreads();

   for (var i = 0; i < threads.size(); i++) {
       var thread = threads.get(i);
       var name = thread.getName();
       gs.info('Thread Name: ' + name);
       // Check if the thread corresponds to your script and terminate it

   }

   

### 3. **Use Script Include to Terminate Script:**

   - Create a Script Include with a method to terminate the running script.

   - Use the `GlideScriptManager` API to terminate the script.

 

   Example Script Include Method:

  

   

var ScriptTerminator = Class.create();
   ScriptTerminator.prototype = {
       terminateScript: function(scriptName) {
           var scriptManager = new GlideScriptManager();
           var scripts = scriptManager.getActiveScripts(scriptName);
           for (var i = 0; i < scripts.size(); i++) {
               var script = scripts.get(i);
               script.terminate(); // Terminate the script
           }
       },
       type: 'ScriptTerminator'
   };

 

   In this example, `scriptName` is the name of the script you want to terminate. Call this method with the name of the stuck script to attempt termination.

 

### 4. **ServiceNow Support:**

   - If you are unable to resolve the issue using the above methods, it's advisable to contact ServiceNow Support. They have specialized tools and access to underlying system components that can assist in troubleshooting and resolving such issues.

 

As always, exercise caution and test any solution in a non-production environment before applying it to your live instance. Terminating scripts should be handled carefully to avoid any unintended consequences.

 

Mark my answer helpful & accepted if it helps you resolve your issue.

 

Thanks,

Danish

sys_script is the Business Rule table, there is no state field and it doesn't manage running transactions.

Hi @Christian_ ,

 

Thanks for pointing out. apologies I got confused. Let me edit the reply.

 

Thanks,

Danish

Jeff Booth
Kilo Guru

Thanks all for your feedback, I've reached out to NOW Support for additional assistance. 

I verified the script was  no longer running (#1), #2 did not return any results, did not attempt #3 - went straight to #4.