Check journal size and clean it up

Show the disk usage, then shrink the journal to 500M and delete entries older than 2 days

journalctl --disk-usage; journalctl --vacuum-size=500M --vacuum-time=2d

tool
journalctl12 commands
tags
journalctldiskperformance

More journalctl commands

  • journalctl -t kernel -t sudo -f --no-hostname

    Follow by SYSLOG_IDENTIFIER, not by unit. -t can be repeated, --no-hostname removes clutter

  • journalctl -u <name> --output=json --output-fields=__REALTIME_TIMESTAMP,MESSAGE,_PID | jq -r '[.__REALTIME_TIMESTAMP,._PID,.MESSAGE]|@tsv'

    Keep only the needed JSON fields and print them as tab-separated columns. __REALTIME_TIMESTAMP is in microseconds

  • journalctl -D /mnt/crashed/var/log/journal -b -1 -p err

    Read journals from another root (rescue or forensics) without copying files

  • journalctl --header | grep -iE 'file|state'; ls -d /var/log/journal 2>/dev/null || echo volatile

    If /var/log/journal is missing, logs live in memory and are lost on reboot. Fix: mkdir + systemd-tmpfiles

  • journalctl -p err -b --no-pager

    Show only err, crit, alert and emerg messages from the current boot. -p also takes a range, for example -p warning..err

all 12 journalctl commands