---
name: "sd_journal_seek_cursor"
section: "3"
platform: "linux"
package: "libsystemd-dev"
version: "257.13-1~deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sd_journal_seek_head"
---

# sd\_journal\_seek\_cursor(3)

Seek to a position in the journal

Part of [sd\_journal\_seek\_head(3)](/sd_journal_seek_head/3.md).

## NAME

sd\_journal\_seek\_head, sd\_journal\_seek\_tail, sd\_journal\_seek\_monotonic\_usec, sd\_journal\_seek\_realtime\_usec, sd\_journal\_seek\_cursor - Seek to a position in the journal

## SYNOPSIS

```
#include <systemd/sd-journal.h>
```

**int sd\_journal\_seek\_head(sd\_journal \****j***);**

**int sd\_journal\_seek\_tail(sd\_journal \****j***);**

**int sd\_journal\_seek\_monotonic\_usec(sd\_journal \****j***, sd\_id128\_t** *boot\_id***, uint64\_t** *usec***);**

**int sd\_journal\_seek\_realtime\_usec(sd\_journal \****j***, uint64\_t** *usec***);**

**int sd\_journal\_seek\_cursor(sd\_journal \****j***, const char \****cursor***);**

## DESCRIPTION

**sd\_journal\_seek\_head()** seeks to the beginning of the journal, i.e. to the position before the oldest available entry.

Similarly, **sd\_journal\_seek\_tail()** may be used to seek to the end of the journal, i.e. the position after the most recent available entry.

**sd\_journal\_seek\_monotonic\_usec()** seeks to a position with the specified monotonic timestamp, i.e. **CLOCK\_MONOTONIC**. Since monotonic time restarts on every reboot a boot ID needs to be specified as well.

**sd\_journal\_seek\_realtime\_usec()** seeks to a position with the specified realtime (wallclock) timestamp, i.e. **CLOCK\_REALTIME**. Note that the realtime clock is not necessarily monotonic. If a realtime timestamp is ambiguous, it is not defined which position is sought to.

**sd\_journal\_seek\_cursor()** seeks to the position at the specified cursor string. For details on cursors, see [**sd\_journal\_get\_cursor**(3)](/sd_journal_get_cursor/3.md). If no entry matching the specified cursor is found the call will seek to the next closest entry (in terms of time) instead.

Note that these calls do not actually make any entry the new current entry, this needs to be done in a separate step with a subsequent [**sd\_journal\_next**(3)](/sd_journal_next/3.md) invocation (or a similar call). Only then, entry data may be retrieved via [**sd\_journal\_get\_data**(3)](/sd_journal_get_data/3.md) or an entry cursor be retrieved via [**sd\_journal\_get\_cursor**(3)](/sd_journal_get_cursor/3.md). If no entry exists that matches exactly the specified seek address, the next closest is sought to. If [**sd\_journal\_next**(3)](/sd_journal_next/3.md) is used, the closest following entry will be sought to, if [**sd\_journal\_previous**(3)](/sd_journal_previous/3.md) is used the closest preceding entry is sought to.

After the seek is done, and [**sd\_journal\_next**(3)](/sd_journal_next/3.md) or a similar call has been made, [**sd\_journal\_test\_cursor**(3)](/sd_journal_test_cursor/3.md) may be used to verify whether the newly selected entry actually matches the cursor.

## RETURN VALUE

The functions return 0 on success or a negative errno-style error code.

## 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.

Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/pkg-config/1.md) file.

## HISTORY

**sd\_journal\_seek\_head()**, **sd\_journal\_seek\_tail()**, **sd\_journal\_seek\_monotonic\_usec()**, **sd\_journal\_seek\_realtime\_usec()**, and **sd\_journal\_seek\_cursor()** were added in version 187.

## SEE ALSO

[**systemd**(1)](/systemd/1.md), [**sd-journal**(3)](/sd-journal/3.md), [**sd\_journal\_open**(3)](/sd_journal_open/3.md), [**sd\_journal\_next**(3)](/sd_journal_next/3.md), [**sd\_journal\_get\_data**(3)](/sd_journal_get_data/3.md), [**sd\_journal\_get\_cursor**(3)](/sd_journal_get_cursor/3.md), [**sd\_journal\_get\_realtime\_usec**(3)](/sd_journal_get_realtime_usec/3.md)
