Operating System - HP-UX
1752808 Members
6705 Online
108789 Solutions
New Discussion юеВ

Re: shutdown with timeout

 
SOLVED
Go to solution
Ryan Kogelheide
Frequent Advisor

shutdown with timeout

We had a network failure the other day on the link to one node of our two node OPS cluster. The node hang shutting down its instances and the other node's instances froze waiting for the first to finish. There can be any number of reasons why a shutdown immediate fails, but I thought I'd write a safer shutdown script. Unfortunately, it doesn't work.

#!/usr/bin/ksh
#-----------------------------------------------------------------------------
# Usage : shutdown.sh SID
# Description : shutdown the Oracle Instance for value given in SID
# This script is called by HP/MC packages
#
# stop the database service $1; if it's not dead
# in $2 seconds, kill the pmon process
#
# Execution : must be launched by Oracle User
#-----------------------------------------------------------------------------

if [ $# -lt 2 ] ; then
echo 'Usage: shutkill.sh "SID" "KILLWAIT"'
exit 1
fi

#
# Set the ORACLE_SID to $1 parameter and call oraenv utility to set
# ORACLE_HOME, PATH etc environment variables
# see oraenv utility for more informations
#

ORACLE_SID=$1; export ORACLE_SID
ORAENV_ASK=NO; export ORAENV_ASK
. oraenv

#
# calc process id of pmon
#
PMON=ps -ef | grep ora_pmon_$ORACLE_SID | grep -v grep | cut -c 9-17

#
# shutdown the "SID" instance
#

cat << EOF > $CMDFILE
connect / as sysdba
shutdown immediate
exit
EOF

sqlplus /nolog @$CMDFILE &
shutproc=$!

# check every 10 seconds to see if shutproc finished
waiting=0
sleep 10
while [[ "`ps -p $shutproc | grep -c .`" = 2 ]]; do
sleep 10
waiting=$((waiting+10));
if [[ $waiting -gt $1 ]]; then
echo Waited more than $1 ($waiting)
echo Error in shutdown, killing pmon proc
# kill $PMON
exit 72
fi
done


This proc returns:

sh: Syntax error: `(' is not expected.

Help oh generous brahmen!
2 REPLIES 2
Steve Steel
Honored Contributor
Solution

Re: shutdown with timeout

Hi

Put set -x as the second line of the script.

Will print the commands as they execute.

Then debug.

Suspect line.
echo Waited more than $1 ($waiting)

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Ryan Kogelheide
Frequent Advisor

Re: shutdown with timeout

That worked... thanks duuude!