Urgent: clear the system logs table

JG6
Kilo Guru

Hello Community,

I'm urgently trying to delete all records from the syslog table. Some runaway code flooded it with millions of entries, causing minutes pauses in the system. Sometimes even crashing it. It's such a mass it's meaningless to erase the rows one by one.

I'd like to run 'Delete all records' on the 'syslog' table. The button unfortunately isn't there. Despite having the 'admin' role.

What I've tried so:

  • Remove the 'nobody' role for deletion => can not delete it. grayed out.
  • Assign myself the 'nobody' role => no effect
  • Include the 'nobody' role into the 'admin' role => no effect

Is there anything else I can try ?

thx !

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use fix script for that

Note: Please test this well before running for entire table

var rec = new GlideRecord('syslog');

rec.query();

rec.deleteMultiple();

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Hi JG,

 In Ankur's script, you may want to do a first pass with:

var rec = new GlideRecord('syslog');

rec.query();

gs.print("# of records: "+rec.getRowCount();

 

And once you confirm get the expected number, replace the rec.query() by rec.deleteMultiple().

 

DeleteMultiple() may take hours to process a large number of records.

 

Question would be: does it delete faster than the log gets populated?

 

You may refresh the syslog list to see if the number of entries increases or decreases.

 

Philippe

Hi,

You can use either of this

1) Schedule job which would run in background

2) Execute fix script in background

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

JG6
Kilo Guru

It took a while to execute, but the logs are purged. MANY thanks Servicenow Community !