You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code was working on Ubuntu 22.04, with python3-systemd version 234:
j=systemd.journal.Reader()
j.this_boot()
j.log_level(systemd.journal.LOG_INFO)
j.add_match(SYSLOG_IDENTIFIER="kernel")
# Seek to the end of the journal to only capture new entriesj.seek_tail()
whileTrue:
ifj.wait(10):
forentryinj:
# do things
But on Ubuntu 24.04 and python3-systemd version 235, it is not working anymore. Especially, the "for" loop does not encounter any item. If we try to run next(j) it immediately raises StopIteration, even if j.wait(timeout) returned APPEND.
@SkytAsul My testing confirmed that every version of Ubuntu from 24.04 has this issue. I did find a workaround, add j.get_previous() immediately after j.seek_tail() in your example code.
I was inspired by looking at this C example code which mentioned having an issue with calling sd_journal_next() immediately after sd_journal_seek_tail().
Attached is the working version of your example Python code and an expanded version of the linked C code above to have the equivalent functionality.
I dont know about ubuntu, but on debian 12.2.0, using python3-systemd (235-1+b2), none of this work.
Typically this example (from the current main github page)
from systemd import journal
from datetime import datetime, timedelta
j = journal.Reader()
j.seek_realtime(datetime.now() - timedelta(minutes=20))
for entry in j:
print(entry['MESSAGE'])
Return either nothing, or few (4) random lines, completely unrelated to what journalctl -f outputs. For example, connecting with ssh will add lines to output of journalctl -f, but none (or the same previous old) lines will be printed by this script.
Trying polling in a lot of different ways, including the original code of this thread, my own original code, and the example_journal_reader.py with an added get_previous() : none of them work. Nothing is displayed. At best entries are all {}, most of the time there are none. Still while double-checking with journalctl -f.
Activity
tests: update rsyslog test to work
tests: update rsyslog test to work
jmanojlovich commentedon Nov 11, 2025
@SkytAsul My testing confirmed that every version of Ubuntu from 24.04 has this issue. I did find a workaround, add
j.get_previous()immediately afterj.seek_tail()in your example code.I was inspired by looking at this C example code which mentioned having an issue with calling
sd_journal_next()immediately aftersd_journal_seek_tail().Attached is the working version of your example Python code and an expanded version of the linked C code above to have the equivalent functionality.
example_journal_reader.py
example_journal_reader.c
orzel commentedon Jun 28, 2026
I dont know about ubuntu, but on debian 12.2.0, using python3-systemd (235-1+b2), none of this work.
Typically this example (from the current main github page)
Return either nothing, or few (4) random lines, completely unrelated to what
journalctl -foutputs. For example, connecting with ssh will add lines to output ofjournalctl -f, but none (or the same previous old) lines will be printed by this script.Trying polling in a lot of different ways, including the original code of this thread, my own original code, and the
example_journal_reader.pywith an addedget_previous(): none of them work. Nothing is displayed. At best entries are all{}, most of the time there are none. Still while double-checking withjournalctl -f.