萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> 編程語言綜合 >> shell 服務狀態監控

shell 服務狀態監控

  #!/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

copyright © 萬盛學電腦網 all rights reserved