SD_JOUR...IME_USEC(3)
π SD_JOURNAL_GET_CUTOFF_REALTIME_USEC(3) & SD_JOURNAL_GET_CUTOFF_MONOTONIC_USEC(3) β the "when did this journal thing even start/end" girlies β¨
Okay bestie, so today we're talking about sd_journal_get_cutoff_realtime_usec and sd_journal_get_cutoff_monotonic_usec β two absolute icons from the sd_journal_get_cutoff_realtime_usec corner of the systemd universe. They read cut-off timestamps from the current journal entry, and honestly? Life-changing if you're into that. π
β¨ SYNOPSIS β¨
Like, the vibes start here:
#include <systemd/sd-journal.h>
int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from,
uint64_t *to);
int sd_journal_get_cutoff_monotonic_usec(sd_journal *j,
sd_id128_t boot_id,
uint64_t *from, uint64_t *to);
π¦ DESCRIPTION π¦
So sd_journal_get_cutoff_realtime_usec() is giving main character energy β it retrieves the realtime (wallclock) timestamps of the first and last entries accessible in the journal. Obsessed. π
It takes three arguments, periodt:
- the journal context object
j - two pointers
fromandtopointing at 64-bit unsigned integers to store the timestamps in
The timestamps are in microseconds since the epoch, i.e. CLOCK_REALTIME. Either one of the two timestamp arguments may be passed as NULL in case the timestamp is not needed β but not both, bestie. π
Now sd_journal_get_cutoff_monotonic_usec() is the lowkey moody sibling. It retrieves the monotonic timestamps of the first and last entries accessible in the journal. Also three arguments:
- the journal context object
j - a 128-bit identifier for the boot
boot_id - two pointers to 64-bit unsigned integers to store the timestamps,
fromandto
The timestamps are in microseconds since boot-up of the specific boot, i.e. CLOCK_MONOTONIC. And since the monotonic clock begins new with every reboot, it only defines a well-defined point in time when used together with an identifier identifying the boot β see sd_id128_get_boot(3) for more info, iykyk. π
The function will return the timestamps for the boot identified by the passed boot ID. Either one of the two timestamp arguments may be passed as NULL in case the timestamp is not needed, but not both (yes, we're saying it again, it's important π
).
πΈ RETURN VALUE πΈ
Both sd_journal_get_cutoff_realtime_usec() and sd_journal_get_cutoff_monotonic_usec() return:
1on success π0if no suitable entries are in the journal- a negative errno-style error code (crying π)
Locations pointed to by parameters from and to will be set only if the return value is positive β and obviously, the parameters are non-null. Not me being like "conditional assignment, slay". β¨
π 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. So like, don't share the same sd_journal object across threads simultaneously, but you can have separate ones, bestie. π§
Functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file. Yes, pkg-config is still a thing. π
π HISTORY π
sd_journal_get_cutoff_realtime_usec() and sd_journal_get_cutoff_monotonic_usec() were added in version 187. Ancient. Iconic. π
π SEE ALSO π
systemd(1)sd-journal(3)sd_journal_open(3)sd_journal_get_realtime_usec(3)sd_id128_get_boot(3)clock_gettime(2)
okay that's the whole thing, bestie π this page was brought to you by systemd 261.3 and the date line β you know the one. go forth and read your journal timestamps with confidence. π«Άβ¨
π¦ 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