核心代码:

复制代码 代码如下:

#/bin/bash
set -x
HOSTS="nginx mysql php-cgi"
for myhost in $HOSTS
  do
  count=(`ps aux |grep $myhost |grep -v grep |wc -l`)
  echo "$myhost"
  echo "$count"

if [ $count -eq 0 ]; then
  case $myhost in
  nginx)
  cd /usr/local/webserver/nginx/sbin/
  ./nginx
  echo "nginx has be down"
  sleep 5

  mysql)
  /etc/init.d/mysqld start
  echo "mysql has be down"

  *)
  echo "what‘s the hell?"

esac
  fi
done
set +x

点赞(96)

评论列表共有 0 条评论

立即
投稿
返回
顶部