2017年4月23日 星期日

omscripts_db_96_mountcheck.sh



#!/bin/bash
# 如果是10g比較好是把前面的SQL提出去變另一個檔案
# ScriptName : mountcheck.sh
# 自動重啟  $1 =  GO
# mountcheck.sh  GO
PATH=$PATH:$HOME/bin

. ~/.bash_profile
S=`sqlplus -s / as sysdba <<EOF
SET HEADING OFF FEEDBACK OFF ECHO OFF PAGESIZE 0
select OPEN_MODE
from v\$database
where 1=1 ;

exit;
EOF`
echo $S
#MOUNT=`echo $S | awk '{print $1}'`

#echo $MOUNT

if [ "$S" = "MOUNTED" ]
then

echo "Mount OK good"

else

if [ "$S" = "READ ONLY" ]
then
echo "Must shutdown NG !!"
if [ "$1" = "GO" ]
then
echo "DO Shutdown"
sqlplus -s / as sysdba <
<EOF
SET HEADING OFF FEEDBACK OFF ECHO OFF PAGESIZE 0
shutdown immediate;
startup mount ;
exit;
EOF

TimeStr=`date +%Y-%m-%dT%H-%M-%S`
STR="TEST STB DB is restart mount as ${TimeStr}"
/omscripts/sendsms.sh "$STR" "177" "300"

fi

fi
fi






omscripts oracle$  cat S_96.sql
select OPEN_MODE
from v$database
where 1=1 ;


沒有留言:

RHEL install EPEL

  https://www.linuxtechi.com/install-epel-repo-on-rhel-system/ EPEL dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest...