sys_audit table is too big ( need a way to clean that using script ) 

RudhraKAM
Tera Guru

1. Can some one help me how to know which table is  have more audits ? by year by year ?,, ( I tried using report ,its timing out as our audit history is too big ) , can we do it with background script ?

Tried this but its not giving any results 

var gr= new GlideRecord("sys_audit");

gr.addEncodedQuery("sys_created_onON2013-07-28@javascript:gs.dateGenerate('2013-07-28','start')@javascript:gs.dateGenerate('2016-07-28','end')");

gr.query();

gs.print(gr.getRowCount());

 

 

and 2. fix script to delete the records which are older than july 4 2015 

 

delCoreCompanyRec();

function delCoreCompanyRec()
{
var gr= new GlideRecord("sys_audit");

gr.addEncodedQuery("sys_created_onON2016-07-28@javascript:gs.dateGenerate('2016-07-28','start')@javascript:gs.dateGenerate('2016-07-28','end')");

gr.setWorkflow(false); //Don't fire Business rule,notifications
gr.deleteMultiple();

}

 

and 3.a schedule job script to delete records which are older than 3 years 

 

 

 

 

9 REPLIES 9

Prateek kumar
Mega Sage

take a look at archive rules

https://docs.servicenow.com/bundle/london-platform-administration/page/administer/database-rotation/...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

I cannot find SYsaudit file in that 😞

I was able to find it in my instance though.


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

We are in london 

find_real_file.png

find_real_file.png