说明: 可以配合ansible进行批量实现
例1: 判断ntp是否启动
systemctl is-active ntpd.service &>/dev/null; if [ $? == 0 ]; then echo "ntp-ok"; else echo "ntp-no" | xargs ;fi
systemctl is-active ntpd.service &>/dev/null; if [ $? == 0 ]; then echo "ntp-ok"; else echo "" | xargs ;fi
systemctl is-active ntpd.service &>/dev/null; if [ $? == 0 ]; then echo "ntp-ok"; else echo "ntp-no";fi; if systemctl is-active chronyd.service &>/dev/null; then echo "chronyd-ok" | xargs ;fi
标签:语句,service,ntp,echo,systemctl,命令行,Linux,active,null From: https://www.cnblogs.com/libin-linux/p/17211744.html