if

#!/bin/sh

hn=`ps axu| grep httpd|wc -l`

if [ $hn -gt 1 ];then                                                     #gt (great then) = 大于

      mn=`ps axu| grep 'mysql'| grep -v 'grep' | wc -l`

  if [ $mn -lt 1 ];then                                                #lt(less then) = 
        echo "`hostname -s`"
    echo 'mysql service  stop'
  fi

fi

实例2

mn = `ps -axu|grep mysql|grep -v 'mysql'`

if [ $mn -ne  0 ]

then
HOST=`hostname -s`
news="mysql service is up"

fi

原文地址:https://www.cnblogs.com/seasonsstory/p/3125858.html