您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> 编程语言综合 >> 正文

shell 服务状态监控

作者:佚名    责任编辑:admin    更新时间:    2015-10-14 18:05:09

  #!/bin/sh

  DBSTAT=`ps -ef|grep 'postmaster'|grep -v 'grep'`

  if [ "$DBSTAT" == "" ];

  then

  echo "DB down"

  DBstus=`ps -ef|grep 'postmaster'|grep -v 'grep'`

  while [ "$DBstus" == "" ];

  do

  if ["$DBstus" == ""];

  then

  echo "DB starting ..."

  /etc/init.d/postgresql start

  DBstus=`ps -ef|grep 'postmaster'|grep -v 'grep'`

  else

  echo "PostgreSQL already running! "

  fi

  done

  else

  echo "DB running"

  fi