SD_JOURNAL_GET_SEQNUM(3)
π sd_journal_get_seqnum π
okay bestie, so this page in the sd_journal_get_seqnum manual is literally about reading the sequence number off the journal entry you're currently sitting on. tiny function, big lore. let's get into it π«Ά
β¨ NAME β¨
sd_journal_get_seqnum β read the sequence number from the current journal entry. yes queen, that's the whole vibe π
πΈ SYNOPSIS πΈ
#include <systemd/sd-journal.h>
int sd_journal_get_seqnum(sd_journal *j, uint64_t *ret_seqnum,
sd_id128_t *ret_seqnum_id);
π¦ DESCRIPTION π¦
so sd_journal_get_seqnum() hands you back the sequence number of the current journal entry. it takes three arguments: the journal context object, a pointer to a 64-bit unsigned integer where the sequence number goes, and a buffer to return the 128-bit sequence number ID in. three little args, no cap β¨
here's the tea on how numbering works π when writing journal entries to disk, each systemd-journald instance numbers them sequentially, starting from 1 for the first entry written after subsystem initialization. and each of those series of sequence numbers is associated with a 128-bit sequence number ID, which gets initialized randomly β once, at systemd-journal initialization. so like, multiple instances of systemd-journald will totally assign the same sequence numbers to the entries they write, but their sequence number IDs will be distinct. iykyk π
the sequence number is assigned at the moment of writing the entry to disk. so if log entries get rewritten (for example because the volatile logs from /run/log/ are flushed to /var/log/ via systemd-journald-flush.service) they will get new sequence numbers assigned. not me getting a whole new identity π
sequence numbers may be used to order entries (entries associated with the same sequence number ID and lower sequence numbers should be ordered chronologically before those with higher sequence numbers), and also to detect lost entries. main character energy fr fr π
heads up though β journal service instances typically write to multiple journal files in parallel (for example because SplitMode= is used), and in that case each journal file will only contain a subset of the sequence numbers. to recover the full stream of journal entries the files must be combined ("interleaved"), a process that primarily relies on the sequence numbers. slay, but also, keep track of your files bestie π
when journal files are rotated (due to size or time limits), the series of sequence numbers is continued in the replacement files. and all journal files generated from the same journal instance will carry the same sequence number ID. consistent queen π
as the sequence numbers are assigned at the moment of writing the journal entries to disk, they lowkey don't exist if storage is disabled via SplitMode=. no disk, no number, no vibes π
the ret_seqnum and ret_seqnum_id parameters may be specified as NULL, in which case the relevant data is not returned (but the call will otherwise succeed). so you can be like "i don't need that one actually" and it's fine π
β οΈ note that these functions will not work before sd_journal_next(3) (or a related call) has been called at least once, in order to position the read pointer at a valid entry. position yourself first, bestie. main character needs a stage β¨
β RETURN VALUE β
sd_journal_get_seqnum() returns 0 on success, or a negative errno-style error code. that's it, that's the scale β zero and slay, or negative and cry π
π NOTES π
- all functions listed here are thread-agnostic, and only a single thread may operate on a given object at any given time. different threads may access the same object at different times. multiple independent objects may be used from different threads in parallel. sharing is caring but respect the boundaries π«Ά
- functions described here are available as a shared library, which can be compiled against and linked to with the
libsystemdpkg-config(1)file. link it, love it, live it π
π HISTORY π
sd_journal_get_seqnum() was added in version 254. vintage-ish, iconic, periodt π
π SEE ALSO π
systemd(1)sd-journal(3)sd_journal_open(3)sd_journal_next(3)sd_journal_get_data(3)sd_journal_get_monotonic_usec(3)
go read those next, bestie, it's giving study group πβ¨
and that's the whole page, bestie π this came from systemd 261.3 β catch you on the next manpage, mwah ππ¦π
π¦ where this page comes from
- ubuntu stonking: libsystemd-dev 261.3-0ubuntu3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms