web-technical-blog

web開発に関する技術メモ

CentOS7のsystemdサービス管理について

systemdでは、これまでサービス起動スクリプトで定義されていたものがUnitという形で定義されます。
サービスの管理=Unitの管理となる。

■有効化されているUnitの一覧表示(list-units)
systemctlコマンドでは--no-pagerオプションを付与するとページ送りされず一気に全て表示される。

$ systemctl list-units
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
sys-devices-pci0000:00-0000:00:01.1-ata3-host2-target2:0:0-2:0:0:0-block-sr0.device loaded active plugged VBOX_CD-ROM VBOXADDITIONS_5.0.16_105871
sys-devices-pci0000:00-0000:00:03.0-net-enp0s3.device loaded active plugged 82540EM Gigabit Ethernet Controller (PRO/1000 MT Desktop Adapte
(--skip--)

crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
● firewalld.service masked active running firewalld.service
getty@tty1.service loaded active running Getty on tty1
jenkins.service loaded active running LSB: Jenkins Continuous Integration Server
● kdump.service loaded failed failed Crash recovery kernel arming
kmod-static-nodes.service loaded active exited Create list of required static device nodes for the current ker
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or pr
lvm2-pvscan@8:2.service loaded active exited LVM2 PV scan on device 8:2
● network.service loaded failed failed LSB: Bring up/down networking
(--skip--)
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
99 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

■インストールされているUnitファイルの一覧表示(list-unit-files)

$ systemctl list-unit-files
UNIT FILE STATE
proc-sys-fs-binfmt_misc.automount static
dev-hugepages.mount static
dev-mqueue.mount static
proc-sys-fs-binfmt_misc.mount static
sys-fs-fuse-connections.mount static
sys-kernel-config.mount static
sys-kernel-debug.mount static
tmp.mount disabled
brandbot.path disabled
systemd-ask-password-console.path static
systemd-ask-password-plymouth.path static
systemd-ask-password-wall.path static
session-1.scope static
auditd.service enabled
(--skip--)
235 unit files listed.

▼参考URL
dev.classmethod.jp