EXPERTS,
I need a UNIX shell script to check the DBs status (Running/Shutdown) in the server.If its Running then no issue but if it is in shutdown state ,it should prompt like " DB is shut down you want to startup??" if i enter YES it should startup.
ORACLE_SID are present in /var/opt/oracle/oratab
check_stat=`ps -ef|grep ${ORACLE_SID}|grep pmon|wc -l`;
oracle_num=`expr $check_stat`
if [ $oracle_num -lt 1 ]
then
exit 0
fi
i tried this.. but the problem is ORACLE_SID is not set. the list of instances can be found in /var/opt/oracle/oratab.. i dont know how to proceed next..
Could you please how exactly the entries are there in oratab file? usually it will have ORACLE_SID:path at which oracle installed:shoudl it use db start or not (Y/N).
If you have multiple entries then you should know which SID you are searching for..
ya there are multiple entries..
the problem is all of the below mentioned DBs will run on that server.if any one of DB goes down,i need to start up that particular DB.
What method do you use to startup the DB? do you use any scripts (in case of dataguard installed) or you log on to SQL as sysdba and run startup?
---------- Post updated at 02:21 PM ---------- Previous update was at 02:13 PM ----------
You can use this..
for line in `awk -F"[#:*]" 'NF==3&&$1~/./{print $1}' /wload/clht/app/etc/oratab` ; do
ps -ef|grep $line|grep pmon > /dev/null
if [ $? -eq 0 ] ; then
echo "DB $line is up and running"
else
echo "DB $line is not running"
#Your DB startup script goes in here I would say set ORACLE_SID to $line before you startup
fi
done
thanks for the script
when i execute this i am getting nothing,
can u please explain the awk part?
for line in `awk -F"[#:*]" 'NF==3&&$1~/./{print $1}' /var/opt/oracle/oratab` ; do
ps -ef|grep $line|grep pmon > /dev/null
if [ $? -eq 0 ] ; then
echo "DB $line is up and running"
else
echo "DB $line is not running"
fi
done