[root@web init.d]# cat orad
#!/bin/sh
# Author: jackylau <squidipt@yahoo.com.cn>;
# chkconfig: 345 99 99
# description: start or stop oracle
. /etc/rc.d/init.d/functions
#oracle_env
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/product/9.2.0
export PATH=$PATH/:$ORACLE_HOME/bin
export ORACLE_SID=oradb
export ORACLE_TERM=vt100
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
oracle_user=oracle
#killproc
start(){
echo -n "starting oracle: "
su - "$oracle_user"<<EOO
lsnrctl start
sqlplus /nolog <<EOS
connect /as sysdba
startup
EOS
EOO
}
stop(){
echo -n "stoping oracle: "
su - "$oracle_user"<<EOO
lsnrctl stop
sqlplus /nolog <<EOS
connect /as sysdba
shutdown immediate
EOS
EOO
}
case "$1" in
start)
start
touch /var/lock/subsys/orad
;;
stop)
stop
rm -f /var/lock/subsys/orad
;;
status)
status oracle
;;
restart)
stop
sleep 3
start
;;
*)
echo "$0 {start|stop|status|restart}"
;;
esac
将此脚本cp到/etc/rc.d/init.d/目录下
加上可执行权限:
chmod 755 /etc/rc.d/init.d/orad
发布:
chkconfig --add orad
即可!