Linux Shell daemon/RAC Restart script

Source: Internet
Author: User

To establish a daemon process:

#! /bin/sh  PRO_NAME=./xxxx.sh while true ; do       #用ps获取$PRO_NAME进程数量       echo ‘‘> nohup.out     NUM=`ps aux | grep -w ${PRO_NAME} | grep -v grep |wc -l`       #echo $NUM       #少于1,重启进程       if [ "${NUM}" -lt "1" ];then           echo "${PRO_NAME} was killed"           ${PRO_NAME} -d      #大于1,杀掉所有进程,重启      elif [ "${NUM}" -gt "1" ];then          echo "more than 1 ${PRO_NAME},killall ${PRO_NAME}"           killall -9 $PRO_NAME          ${PRO_NAME} -d       fi       #kill僵尸进程       NUM_STAT=`ps aux | grep -w ${PRO_NAME} | grep T | grep -v grep | wc -l`       if [ "${NUM_STAT}" -gt "0" ];then           killall -9 ${PRO_NAME}           ${PRO_NAME} -d      fi       sleep 5s   done   exit 0

Create a script that restarts db (for RAC use only), purely for convenience:

#!/bin/bashif [ $1 ]then{db_name=$1srvctl stop database -d $db_name -o abortnum=`ps -ef|grep -i smon_|grep -v grep|grep -v -i asm|awk ‘{print $2}‘ `if [ ! $num ]thenecho "database restart........."fiwhile [ "$num" ]dosleep 1num=`ps -ef|grep -i smon_|grep -v grep|grep -v -i asm |awk ‘{ print $2  }‘`echo "database not shutdown ,please check!" donesrvctl start database -d $1num=`ps -ef|grep -i smon_|grep -v grep|grep -v -i asm |awk ‘{ print $2 } ‘`if [ $num ]thenecho "database starting "fiif [ ! -n "$num" ]thenecho "start fail"elseecho  "start sucessfully"fi}elseecho "No parameter ,eg: ./stop_db.sh dbname"fi

Linux Shell daemon/RAC Restart script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.