1、root用户下生成shell脚本放在/etc/init.d/下
eg:
shell name: oracle10gAuto
#chkconfig: 2345 99 01
#description: ORACLE 10g Server
ORACLE_HOME=/oracle/app/oracle/product/10.2.0/db_1
#判断dbstart命令是否存在
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "Oracle cannot start"
exit
fi
#判断lsnrctl命令是否存在(可要可不要)
if [ ! -f $ORACLE_HOME/bin/lsnrctl ]
then
echo "lsnrctl cannot start"
exit
fi
case "$1" in
'start')
echo "starting oracle ......."
su - oracle -c "$ORACLE_HOME/bin/dbstart"
# su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole"
;;
'stop')
echo "stoping oracle ......."
# su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"
# su - oracle -c "$ORACLE_HOME/bin/lsnrctl stop"
su - oracle -c "$ORACLE_HOME/bin/dbshut"
;;
*)
echo "usage $0: start | stop"
;;
esac
2、 增加oracle10gAuto执行权限
chmod a+x /etc/init.d/oracle10gAuto
3、设置自动启动
chkconfig oracle10gAuto on
查看是否设置成功
chkconfig oracle10gAuto --list
eg:
shell name: oracle10gAuto
#chkconfig: 2345 99 01
#description: ORACLE 10g Server
ORACLE_HOME=/oracle/app/oracle/product/10.2.0/db_1
#判断dbstart命令是否存在
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "Oracle cannot start"
exit
fi
#判断lsnrctl命令是否存在(可要可不要)
if [ ! -f $ORACLE_HOME/bin/lsnrctl ]
then
echo "lsnrctl cannot start"
exit
fi
case "$1" in
'start')
echo "starting oracle ......."
su - oracle -c "$ORACLE_HOME/bin/dbstart"
# su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole"
;;
'stop')
echo "stoping oracle ......."
# su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"
# su - oracle -c "$ORACLE_HOME/bin/lsnrctl stop"
su - oracle -c "$ORACLE_HOME/bin/dbshut"
;;
*)
echo "usage $0: start | stop"
;;
esac
2、 增加oracle10gAuto执行权限
chmod a+x /etc/init.d/oracle10gAuto
3、设置自动启动
chkconfig oracle10gAuto on
查看是否设置成功
chkconfig oracle10gAuto --list