journalctl - remove logs of a specific unit

audeoudh picture audeoudh · Apr 19, 2016 · Viewed 17.8k times · Source

With journalctl, it is possible to remove the old logs, by specifying either the maximum disk space they can use, or the maximum age they can have, or the maximum number of separate journal files (using the options --vacuum-size, --vacuum-time or --vacuum-files).

Is there a way to restrain this deletion to a specific systemd unit ?

journalctl -u <unit> --vacuum-time=2d seems not to work as desired: according to the documentation, -u only works when displaying logs.

Answer

user3144605 picture user3144605 · Jun 20, 2016

After some research I found that you can't delete logs for a specific systemd unit, because the logs are interlaced and if you delete only one unit you'll corrupt the logs, so journalctl doesn't let you.