How can I get the logs that appear before my system shuts down?

Whenever I shutdown my computer, I can see some logs appearing just before it completes the shutdown process. For example, I execute profile-cleaner as a startup command, I’m able to see its output before the shutdown occurs.

However, I’m unable to find the specific command to access these logs.journalctl -b displays kernel boot logs and what not, but it doesn’t include the logs I’m seeking.

That command shows the current boot, the shutdown happens in the future.

$ journalctl --help
journalctl [OPTIONS...] [MATCHES...]

Query the journal.

     --system                Show the system journal
     --user                  Show the user journal for the current user
  -M --machine=CONTAINER     Operate on local container
  -S --since=DATE            Show entries not older than the specified date
  -U --until=DATE            Show entries not newer than the specified date
  -c --cursor=CURSOR         Show entries starting at the specified cursor
     --after-cursor=CURSOR   Show entries after the specified cursor
     --show-cursor           Print the cursor after all the entries
     --cursor-file=FILE      Show entries after cursor in FILE and update FILE
  -b --boot[=ID]             Show current boot or the specified boot
     --list-boots            Show terse information about recorded boots
  -k --dmesg                 Show kernel message log from the current boot
  -u --unit=UNIT             Show logs from the specified unit
     --user-unit=UNIT        Show logs from the specified user unit
  -t --identifier=STRING     Show entries with the specified syslog identifier
  -p --priority=RANGE        Show entries with the specified priority
     --facility=FACILITY...  Show entries with the specified facilities
  -g --grep=PATTERN          Show entries with MESSAGE matching PATTERN

or take a look at

man journalctl

I’m looking for the log/output of the programs that are executed at startup. It’s something that has already happened. I’m not talking about the systemd shutting down verbose output, you know, the one that says which service or process is being closed, I’m talking about the logs of the programs that had already been executed at startup. I can see the output just before the systemd shutdown process starts or whatever it’s called.

I already did and I mentioned that I didn’t find anything. Maybe I’m just dumb, but I’ve tried everything and nothing works.

This shows the logs from the previous boot. You can skip to the end with uppercase G and scroll around from there.

journalctl -b -1

This does show the systemd’s shutdown logs, but as I mentioned, that’s not what I’m looking for. I can’t provide images because the quality is too poor, and I can’t take a screenshot for obvious reasons. However, before it shuts down, I see outputs from dbus-daemon, wlr, sway, fnott, etc. I can’t find these logs or outputs anywhere, and I’m not sure if they are being logged by journalctl at all.

The only reason I’m looking for these logs is because every time I attempt to start recording with the FFmpeg VAAPI H.264 video encoder in OBS, the entire session crashes. I’ve been able to capture the logs/error messages that appear just before the crash (it’s the same screen I see when I reboot or shut down my PC), but unfortunately, the text isn’t fully visible.

That shows all the logs from the time the system started to the time it shutdown. If what you are looking for was logged, it should be in there somewhere.

These are perhaps messages displayed on the console you are seeing? Those might not be logged at all.

Yeah, I don’t think it’s being logged. I’m using greetd with tuigreet, so maybe it’s the TTY output or something? Honestly, I’m not sure how to access it after starting Sway.

Switch to the correct TTY. It may be at Ctrl+Alt+F1 or try all the TTYs until you find it.

Problem solved.

It was actually Sway output, which were not being logged to systemd, making them inaccessible to me.

I run Sway through a wrapper script located in /usr/local/bin/ called sway-run. This method is recommended for starting Sway when using greetd (I’m using it with tuigreet. See greetd/wiki). The script itself explains how to direct Sway outputs to the journal.

# If you use systemd and want sway output to go to the journal, use this
# instead of the `exec sway $@` above:
# exec systemd-cat --identifier=sway sway $@

So now I use exec systemd-cat --identifier=sway dbus-run-session sway $@ to start a session bus instance.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.