0

Like there is a way to show all logs belonging to a unit: journalctl -xu <unit>, Is there a way to clear the logs belonging to a specified unit with journalctl ?

Actually, my problem is, one of the service which is imported (from Sys-V /etc/init.d file automatically by systemd) is logging and that is seen in both syslog as well as journal!

I want to remove the logs from the journal as it eats up a lot of space! From the manuals, there is no way to tell journald to NOT persist certain logs! I don't want to forward all logs to syslog ! So, I am thinking, if I could periodically remove the said unit's logs from journal, it will be a huge win!

Ani
  • 32
  • 2
  • 13
  • As i wouldn't disable journald altogether, it's possible to define a "max storage". E.g. Add `SystemMaxUse=100M` to `/etc/systemd/journald.conf` to only keep the last 100MB of all journald logs. – eDonkey May 11 '22 at 08:07
  • maxstorage will only restrict the amount of space taken by journal logs! I searched high and low, there seems to be no option to clear specific logs! – Ani May 12 '22 at 09:05
  • Ohh i see.. My bad, I didn't read it correct. AFAIK you can't "tell" journald what it should/shouldn't log or that only specific logs should be persistent. You'd have to write a script to achieve what you want. – eDonkey May 12 '22 at 11:01

0 Answers0