I'm writing a script to automatically install a bind server on a CentOs 7 distribution.
I'm stuck with systemctl status
, because it does not produce an error code (it's right, since a status is not an error) I can use.
What I want is to check whether the service is started (active). What is the best and efficient way to do this?
systemctl status
does return a status - as I found when doingsystemctl status openvpn@<>
. Where the values are0
for running, and3
for stopped. However, this command is interactive :(. Hence the @lars suggestedsystemctl is-active
is the way to go, and better att the-q
as suggested by @palswim – Googly