systemctl
komut dosyası için uygun bir moda sahip; show
yerine kullanın status
ve yalnızca istediğiniz çıktıyı elde etmek için -p
/ --properties
ve --value
seçeneklerini ekleyin .
İşte bir örnek (bir Ubuntu 17.04 sisteminden):
$ systemctl show -p SubState --value NetworkManager
running
Koşmak (ya da başka şekilde) a SubState
. Bir servisin aktif olup olmadığını bilmek istiyorsanız, özelliği kullanın.ActiveState
$ systemctl show -p ActiveState --value x11-common
inactive
$ systemctl show -p SubState --value x11-common
dead
Notlardan man
:
show [PATTERN...|JOB...]
Show properties of one or more units, jobs, or the manager
itself. If no argument is specified, properties of the
manager will be shown. If a unit name is specified, properties
of the unit are shown, and if a job ID is specified,
properties of the job are shown. By default, empty properties
are suppressed. Use --all to show those too. To select specific
properties to show, use --property=. This command is intended
to be used whenever computer-parsable output is required. Use
status if you are looking for formatted human-readable output.
-p, --property=
When showing unit/job/manager properties with the show command,
limit display to properties specified in the argument. The
argument should be a comma-separated list of property names,
such as "MainPID". Unless specified, all known properties are
shown. If specified more than once, all properties with the
specified names are shown. Shell completion is implemented for
property names.
--value
When printing properties with show, only print the value, and
skip the property name and "=".
inactive
veyaactivating
her ikisystemctl status
vesystemctl is-active
(itibarıyla çıkış 3 ile systemd-241 Geçici):systemctl show service | grep -qx ActiveStatus=activating