3

For a demo, I would like to use systemctl status to show the status of a service in human-friendly form, but hiding the log part:

### I Want that ####################################

root@bulbizarre:/home/sylvain# systemctl status ssh.service
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
   Active: active (running) since Tue 2018-10-09 10:51:59 CEST; 3 days ago
  Process: 1735 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCES
  Process: 1729 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
  Process: 1194 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 1240 (sshd)
    Tasks: 1 (limit: 4915)
   Memory: 1.9M
      CPU: 80ms
   CGroup: /system.slice/ssh.service
           └─1240 /usr/sbin/sshd -D

### But not that ####################################

Oct 09 10:52:26 bulbizarre systemd[1]: Reloaded OpenBSD Secure Shell server.
Oct 09 10:52:26 bulbizarre sshd[1240]: Server listening on 0.0.0.0 port 22.
Oct 09 10:52:26 bulbizarre sshd[1240]: Server listening on :: port 22.
Oct 09 13:57:52 bulbizarre sshd[6966]: pam_unix(sshd:auth): authentication failu
Oct 09 13:57:52 bulbizarre sshd[6966]: pam_ldap(sshd:auth): Authentication failu
Oct 09 13:57:54 bulbizarre sshd[6966]: Failed password for sylvain from 10.129.3
Oct 09 13:57:57 bulbizarre sshd[6966]: pam_ldap(sshd:auth): Authentication failu
Oct 09 13:58:00 bulbizarre sshd[6966]: Failed password for sylvain from 10.129.3
Oct 09 13:58:02 bulbizarre sshd[6966]: Accepted password for sylvain from 10.129
Oct 09 13:58:02 bulbizarre sshd[6966]: pam_unix(sshd:session): session opened fo

Is there some hidden option for that? I know about the -o option, but AFAIK there is no "empty" format.

2

How stupid I am! Right after having asked the question I've got an illumination and I tried that:

systemctl --lines 0 status ssh.service
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-10-09 10:51:59 CEST; 3 days ago
  Process: 1735 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
  Process: 1729 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
  Process: 1194 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 1240 (sshd)
    Tasks: 1 (limit: 4915)
   Memory: 1.9M
      CPU: 80ms
   CGroup: /system.slice/ssh.service
           └─1240 /usr/sbin/sshd -D
   -n, --lines=
       When used with status, controls the number of journal lines to show, counting from the
       most recent ones. Takes a positive integer argument. Defaults to 10.

It is not obvious from the man if this is supposed to work that way (n should be positive, not sure if it includes zero), anyway setting --lines=0 remove the log completely (including the empty separator line).

| improve this answer | |

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.