You are not logged in.

#1 2024-03-08 16:22:28

Albion
Member
Registered: 2019-03-09
Posts: 2

How to see SystemD service error output

When a SystemD service fails I can use the commands

# systemctl status <service-name>

Assuming I have given service:
[Unit]
Description=Load encryption keys
DefaultDependencies=no
After=zfs-import.target
Before=zfs-mount.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/zfs load-key -a
StandardInput=tty-force

[Install]
WantedBy=zfs-mount.service

And I get somethin like:
systemctl status zfs-load-key.service                                                    ~
× zfs-load-key.service - Load encryption keys
     Loaded: loaded (/etc/systemd/system/zfs-load-key.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Fri 2024-03-08 16:51:30 CET; 26min ago
    Process: 1974 ExecStart=/usr/bin/zfs load-key -a (code=exited, status=255/EXCEPTION)
   Main PID: 1974 (code=exited, status=255/EXCEPTION)
        CPU: 110ms

Mär 08 16:51:29 vbm systemd[1]: Starting Load encryption keys...
Mär 08 16:51:30 vbm systemd[1]: zfs-load-key.service: Main process exited, code=exited, status=255/>
Mär 08 16:51:30 vbm systemd[1]: zfs-load-key.service: Failed with result 'exit-code'.
Mär 08 16:51:30 vbm systemd[1]: Failed to start Load encryption keys.

All I get is "zfs-load-key.service: Failed with result 'exit-code'."
However it does not print me the error output of the internal command
of 'ExecStart' which here is the command

#/usr/bin/zfs load-key -a

How can I make the error output of the internal command (here zfs load-key -a) visible?

Offline

#2 2024-03-08 17:00:46

seth
Member
Registered: 2012-09-03
Posts: 51,553

Re: How to see SystemD service error output

Please use [code][/code]. Edit your post in this regard.

Try

sudo journalctl -u <service-name>

Offline

#3 2024-03-08 18:35:04

mountaintrek
Member
Registered: 2024-02-01
Posts: 18

Re: How to see SystemD service error output

I agree with Seth.

What I did was to create a function that did both. If a unit fails, but retries and you need to know its' entire startup to address the situation,  you won't know from just the systemctl command.

systemctl status "${1:-lightdm}" --no-pager --full ; echo '--' ; journalctl -b -u "${1:-lightdm}" --no-pager

Offline

Board footer

Powered by FluxBB