Background script stops after 5 mins
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2022 07:16 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2022 01:07 PM
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.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 04:33 AM
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..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 05:55 AM
Fix script also does the same.
follow link to enable rollback
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0761248
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 05:10 AM
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.