- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2021 12:07 AM
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 !
Solved! Go to Solution.
- Labels:
-
Platform and Cloud Security
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2021 12:15 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2021 01:52 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2021 01:56 AM
Hi,
You can use either of this
1) Schedule job which would run in background
2) Execute fix script in background
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 05:10 AM
It took a while to execute, but the logs are purged. MANY thanks Servicenow Community !