从“systemctl status”输出中隐藏“log”部分

从“systemctl status”输出中隐藏“log”部分

对于演示,我想用来systemctl status以人性化的形式显示服务的状态,但隐藏日志部分:

### 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

有一些隐藏的选项吗?我知道这个-o选项,但据我所知,没有“空”格式。

答案1

我多么愚蠢啊!在问完这个问题后,我得到了启发,我尝试了:

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.

从这man是否应该以这种方式工作(n应该是积极的,不确定是否包括),无论如何设置--lines=0完全删除日志(包括空分隔符行)。

相关内容