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 statusdoes return a status - as I found when doingsystemctl status openvpn@<>. Where the values are0for running, and3for stopped. However, this command is interactive :(. Hence the @lars suggestedsystemctl is-activeis the way to go, and better att the-qas suggested by @palswim – SACHIN GARG Jul 14 '16 at 18:51