71

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.

audeoudh
  • 1,279
  • 1
  • 8
  • 23

1 Answers1

81

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.

user3144605
  • 1,062
  • 1
  • 11
  • 8
  • 11
    Indeed, it seems that one *must* use `journalctl` to manipulate `systemd`'s logs… and that `journalctl` itself is not able to do the stuff… – audeoudh Jun 20 '16 at 11:43
  • 3
    https://unix.stackexchange.com/questions/272662/how-do-i-clear-journalctl-entries-for-a-specific-unit-only/ – 0andriy May 28 '18 at 07:42
  • 22
    That's a major shortcoming. I accidentally wrote some information to the log that should not have been exposed. I wanted to delete only my unit's logs. My only recourse was to delete everyone else's logs, too. journalctl needs to add support for -u unit-name when used with --vacuum-x .... – Scott Mar 20 '20 at 23:36