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

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

Hi Ankur,

 

FYI, you don't need to do a query() before a deleteMultipe().

Have a look at the example at

https://developer.servicenow.com/dev.do#!/reference/api/orlando/server_legacy/c_GlideRecordAPI#r_GlideRecord-deleteMultiple

 

My modest contribution 🙂

Thank you for correction.

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

JG6
Kilo Guru

Many thanks indeed for the speedy response !

Is it correct to run it in "scripts - background" ? The script seems to hang and the table doesn't seem to contain less records. Yet ?