利用shell 来检查Oracle数据库状态
运行结果返回Oracle 数据库的状态
#! /usr/bin/ksh #+++++++++++++++++++++++++++++++++++++++++++++ # Get ORACLE_SID DB Satus of # # Param 1 : ORACLE_SID #+++++++++++++++++++++++++++++++++++++++++++++ if [ $# -ne 1 ] then echo "Syntax : get_db_status <oracle_sid>" exit 8 fi sql_script=/TEMP/get_db_status.$$.sql sql_script_out=$sql_script.out echo "connect / as sysdba" > $sql_script echo " " >> $sql_script echo " " >> $sql_script echo "set head off" >> $sql_script echo "set pagesize 0" >> $sql_script echo "set linesize 1000" >> $sql_script echo "select open_mode from v\$database;" >> $sql_script echo "exit" >> $sql_script su - oradu8 -c "sqlplus -s /NOLOG @$sql_script" >$sql_script_out 2>/dev/null 0</dev/null status=$( grep 'STATUS:' $sql_script_out| awk '{printf("%s %s\n",$2,$3)}' ) echo ${status}
来源:https://www.cnblogs.com/tingxin/p/12210287.html