[root@oracle init.d]# vim oracle
#!/bin/sh
# chkconfig: 35 80 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
# Set ORA_OWNER to the user id of the owner of the
# Source function library.
. /etc/rc.d/init.d/functions
# Oracle database in ORA_HOME.
ORA_HOME=/usr/local/oracle/product/10201
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# echo "Starting Oracle Databases ... "
action $"Starting $ORA_OWNER: " /bin/true
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
echo "Done"
# Start the Listener:
# echo "Starting Oracle Listeners ... "
action $"Starting $ORA_OWNER Listeners ...: " /bin/true
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
date +" %T %a %D : Finished." >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
'stop')
# Stop the Oracle Listener:
action $"Stoping $ORA_OWNER Listeners ...: " /bin/true
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
rm -f /var/lock/subsys/oracle
# Stop the Oracle Database:
# echo "Stoping Oracle Databases ... "
action $"Stoping $ORA_OWNER: " /bin/true
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
echo ""
'restart')
$0 stop
$0 start
esac
[root@oracle init.d]# chmod 755 /etc/init.d/oracle
[root@oracle init.d]# chkconfig --level 2435 oracle on
[root@oracle init.d]# chkconfig --list|grep oracle
oracle 0:off 1:off 2:on 3:on 4:on 5:on 6:off
要加入自启动,必须要在下面文件中将N改成Y
[root@oracle init.d]# vim /etc/oratab
bill:/usr/local/oracle/product/10201:Y ====>此处原来为N
本文转自陈继松 51CTO博客,原文链接:http://blog.51cto.com/chenjisong/1738196,如需转载请自行联系原作者