From ed84e24914405e03dc6a7ce62f50d9d2d784d148 Mon Sep 17 00:00:00 2001 From: hackersean Date: Tue, 27 Feb 2024 17:48:02 +0800 Subject: [PATCH] Optimized the active judgment command --- pkg/cluster/module/systemd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cluster/module/systemd.go b/pkg/cluster/module/systemd.go index f38387b676..cb2546aae0 100644 --- a/pkg/cluster/module/systemd.go +++ b/pkg/cluster/module/systemd.go @@ -77,7 +77,7 @@ func NewSystemdModule(config SystemdModuleConfig) *SystemdModule { systemctl, strings.ToLower(config.Action), config.Unit) if config.CheckActive { - cmd = fmt.Sprintf("if [[ $(%s is-active %s) == \"active\" ]]; then %s; fi", + cmd = fmt.Sprintf("if %s is-active %s &>/dev/null; then %s; fi", systemctl, config.Unit, cmd) }