我想列出所有已启用的服务实例。
下面列出了启用的服务,但仅显示服务,而不显示单个实例:
systemctl list-unit-files --state=enabled
Run Code Online (Sandbox Code Playgroud)
以下列出了所有正在运行的实例:
systemctl list-units --state=running
Run Code Online (Sandbox Code Playgroud)
我希望像下面这样显示启用的实例:
systemctl list-units --state=enabled
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。
因此,如果我启动两个服务实例:
systemctl start foo-service@primary
systemctl start foo-service@secondary
Run Code Online (Sandbox Code Playgroud)
...但是我只启用一个:
systemctl enable foo-service@secondary
Run Code Online (Sandbox Code Playgroud)
我能够找出启用了哪些实例的唯一方法是:
ls /etc/systemd/system/multi-user.target.wants/
Run Code Online (Sandbox Code Playgroud)
但这看起来很混乱。有没有系统方法可以做到这一点?如果重要的话,版本是 232。