systemd / systemd/systemd

Show the last x log entries when using cursor or dates

Open
#14,722 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

journal
Dominant language
C
Stars
16.7k
Forks
4.7k
Avg merge
1d 6h
Merged PRs (30d)
140

Description

Is your feature request related to a problem? Please describe.
I am trying to get the last x lines of logs and then later get the last x lines of logs as long as they are after the initial load cursor. The --after-cursor parameter does what I want until there are more than x lines between commands, then it shows x lines "after the cursor" instead of the last x lines.

journalctl -n 100 --show-cursor

journalctl -n 100 --after-cursor='<cursor>' - shows 100 lines after the cursor

My current workaround (which is much slower when line count gets large):
journalctl --after-cursor='<cursor>' | tail -n 100 - Shows 100 lines from the end but after the cursor

Describe the solution you'd like
I would like to be able to specify to always get the last log lines. Adding an option like --tail makes the most sense to me.
journalctl -n 100 --tail --after-cursor='<cursor>'

This could also apply to --since and --until. If you wanted the last 100 lines from today:
journalctl -n 100 --tail --since='2019-01-01'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the journalctl commands in the issue, comparing --after-cursor and --since/--until with and without -n. Read the journalctl option handling and retrieval path, then define how a tail-style mode should behave when the range contains more entries than requested. Done means the requested final entries are returned for cursor and date ranges, with coverage for the examples described.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
cli, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.