"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設定に関係なくログ(空の区切り線を含む)を完全に削除します。

おすすめ記事