Background script stops after 5 mins

sathis sky
Tera Contributor

Hi,

 

When script runs for counting Discovered item that does not have vulnerable item. It takes so much times to completed. After 5 mins of running, Scripts screen error as "Service interrupt, this instance is unavailable". Unable to get any results. some things, Script continue to runs in backgrounds and needs to kill it in active transitions. But we don't get count or rollback option.

Please provide suggestion to clear this error.


Script which try to run:

var diCount = 0;
var dicount2 = 0;
var di = new GlideRecord('sn_sec_cmn_src_ci');
di.addEncodedQuery('state=unmatched');
di.query();

gs.log('total count of the DI in this filter: ' + di.getRowCount());

while (di.next()) {

//Checking Di has VITs
var vit = new GlideAggregate('sn_vul_vulnerable_item');
vit.addQuery('src_ci', di.sys_id);
vit.addAggregate('COUNT');
vit.query();
var count = 0;
if (vit.next())
count = vit.getAggregate('COUNT');

if (count == 0) {
diCount++;
} else
dicount2++;
}
gs.log('total di count without VIT : ' + diCount);
gs.log('total di count with VIT : ' + dicount2);

6 REPLIES 6

Aman Kumar S
Kilo Patron

Are you running this in your personal dev instance?

I have seen this happening when you try to run this in background script.

I would suggest to either use fix script or scheduled job to run this, then you should observe any issue as such.

 

Do let me know if it works out.

Best Regards
Aman Kumar

It happens on all instance either personal instance or Client instance. 

Background script gives clear feedback or output and also give better roll back options. Fix script output is not clear.. 

Fix script also does the same.

follow link to enable rollback

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0761248

 

Best Regards
Aman Kumar

Chris McDevitt
ServiceNow Employee
ServiceNow Employee

Hi,

The best practice is to place long-running scripts into Fix Scripts.

The technical issue is that the "UI Transactions" Quota Rule is timing out the transaction.