Score:0

systemd journal - delete logs belonging to a specified unit?

id flag

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!

eDonkey avatar
sl flag
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.
id flag
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!
eDonkey avatar
sl flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.