====== systemd Logs (journalctl) ======
[[http://man7.org/linux/man-pages/man1/journalctl.1.html|journalctl(1) – man7.org]]
^ Flag ^ Effect |
| -b | current boot |
| -b -2 | second to last boot |
| -e | jump to end |
| -x | descriptions |
===== delete the journal =====
You don't typically clear the journal yourself. That is managed by systemd itself and old logs are rotated out as new data comes in. Vacuuming removes archived journal files, not active ones. To get rid of everything, you need to rotate the files first so that recent entries are moved to inactive files.
journalctl --rotate
journalctl --vacuum-time=1s
(you cannot combine this into one journalctl command.)
Some distributions have journald configured so that it writes logs to ''/var/log/journal'' while others keep logs in memory (''/run/log/journal''). In some cases it may be necessary to use ''journalctl --flush'' first to get everything removed.
===== Troubleshooting =====
==== Specifying boot ID has no effect, no persistent journal was found ====
You have to persist the journal for it to be available across reboots, else it'd just be stored in volatile storage, i.e. memory.
mkdir -p /var/log/journal
systemd-tmpfiles --create --prefix /var/log/journal
# reload journald service configuration
killall -USR1 systemd-journald
([[https://gist.github.com/JPvRiel/b7c185833da32631fa6ce65b40836887|source]])