I spent a few days writing a python script, and creating a systemd unit file for it. During testing, the script logged a lot of errors to journald. I would like to clear those errors from journald now that I'm done.
There are several ways to clear the entire journal, as described here: How to clear journalctl
including using journalctl --vacuum-time=2d
, using journalctl --vacuum-size=500M
, and temporarily setting SystemMaxUse=
in /etc/systemd/journald.conf to a very low value.
All of these appear to clear the entire journal, effecting all units. I just need to clear the entries for a single unit. Is this possible?
Best Answer
Use my Python 3 program copy_journal.py on the journal files in
/var/log/journal
from which you want to remove entries.For instance, to make a copy of
system.journal
without log entries forNetworkManager.service
: