How to obtain the current value of _BOOT_ID in systemd-journald?

I can do something ugly such like:

journalctl -o verbose  --since '2016-05-17' | egrep '^[ ]+_BOOT_ID' | tail -n 1| cut -d"=" -f2

Is there a more clever way of do that?

  • If you're in fact interested in seeing the journal, not the boot ID, you could use journalctl -b --since '2016-05-17' which will give you the log for the current boot starting with that date. Apr 3 '18 at 1:30

Alternate method:

cat  /proc/sys/kernel/random/boot_id

This version contains some dashes. The formatting of the boot ID output by journalctl contains no dashes.

The random(4) man page mentions it:

/proc interfaces

  The files in the directory /proc/sys/kernel/random (present since 2.3.16) provide additional information about the /dev/random device:

  uuid and boot_id

  These read-only files contain random strings like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9. The former is generated afresh for each read, the latter was generated once.

  • 1
    Ok, we can use tr -d '-' < /proc/sys/kernel/random/boot_id in order to delete dashes.
    – sebelk
    May 19 '16 at 20:26

journalctl --list-boots | head -1 | cut -d ' ' -f 3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.