brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: journalctl --show-cursor and --after-cursor continue where you stopped

Journalctl
~/tips/tip-journalctl-cursor-continue-after

journalctl --show-cursor -n 20

Shows an opaque bookmark after the last line so a later run can continue from there.

A script that reads the journal in pieces needs a way to remember its place.

--show-cursor prints a cursor after the last entry, as -- cursor: s=.... Pass that string to --after-cursor next time and you get only the entries written since. The cursor points at a position, so it survives rotation and restarts.

journalctl --show-cursor -n 20
journalctl --after-cursor='<cursor>'

The format of the cursor is private and may change, so store it as an opaque string and never try to parse it.

Further reading: journalctl(1) manual page

More Journalctl tips journalctl -k -g 'killed process' --since "2 days ago" journalctl _PID=1 -b ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys All Journalctl tips (81) All topics

Link