How to see full log from systemctl status service?

  • I check service status with systemctl status service-name.

    By default, I see few rows only, so I add -n50 to see more.

    Sometimes, I want to see full log, from start. It could have 1000s of rows.
    Now, I check it with -n10000 but that doesn't look like neat solution.

    Is there an option to check full systemd service log similar to less command?

    While the accepted answer wasn't useful for me, I was not aware of the `-n` flag. Adding `-n99999` seems to be an acceptable workaround for me. Thanks for pointing me in the right direction :-)

  • larsks

    larsks Correct answer

    5 years ago

    Just use the journalctl command, as in:

    journalctl -u service-name.service
    

    Or, to see only log messages for the current boot:

    journalctl -u service-name.service -b
    

    For things named <something>.service, you can actually just use <something>, as in:

    journalctl -u service-name
    

    But for other sorts of units (sockets, targets, timers, etc), you need to be explicit.

    In the above commands, the -u flag is short for --unit, and specifies the name of the unit in which you're interested. -b is short for --boot, and restricts the output to only the current boot so that you don't see lots of older messages. See the journalctl man page for more information.

    appending `--no-pager` will print full log, so you wont have to scroll

    appending `-e` will start the log at the end removing the need to scroll, but without printing the entire log beforehand.

    appending `-f` will follow (print) updates to the log

    appending `--help` will let you see all available options

    are these logs being stored somewhere on the disk?

    @viveksinghggits generally, although it depends on your configuration, but you still need to use `journalctl` to access them.

    Actually, this was not helpful for me - I want only the output since the unit was (re)started. `sudo systemctl -n 99999 status` gives me that, but apparently journalctl can only filter "from boot", not "from service start".

    I assume `--no-pager` will allow it to be piped? (say, to `grep`?)

    `--no-pager` is not necessary when piping the output. It's only useful to disable the pager when output is to an interactive terminal. `journalctl` does not use a pager when you're piping the output to something else.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM