oracle启停脚本

#!/bin/bash
#chkconfig: 345 99 10
#description: script for oracle database

. /etc/rc.d/init.d/functions

LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/opt/oracle/app/product/11.2.0/dbhome_1
ORACLE_USER=oracle


case "$1" in
'start')
if [ -f $LOCKFILE ]; then
echo $0 already running.
exit 1
fi
echo -n $"starting oracle Database:"
echo "su - $ORACLE_USER -c '$ORACLE_HOME/bin/dbstart'"
su - oracle -c "/opt/oracle/app/product/11.2.0/dbhome_1/bin/dbstart"
touch $LOCKFILE
;;
'stop')
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
exit 1
fi
echo -n $"stopping oracle database:"
echo "su - $ORACLE_USER -c '$ORACLE_HOME/bin/dbshut'"
su - oracle -c "/opt/oracle/app/product/11.2.0/dbhome_1/bin/dbshut"
rm -f $LOCKFILE
;;
'restart')
$0 stop
$0 start
;;
'status')
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped
fi
;;
*)
echo "Usage: $0 [start|stop|status|restart]"
exit 1
esac


exit 0

posted @ 2017-11-22 09:33  rocky-2013  阅读(151)  评论(0)    收藏  举报