> 数据库 > Oracle >

Linux下自动启动和关闭ORACLE的脚本

自动启动ORACLE服务
在oracle用户下:
vi Start_ORA.sh
--------------------------------
echo "Begin to start the oracle!"
lsnrctl start
sqlplus /nolog <<EOF
connect /as sysdba
startup
exit
EOF
echo "Oracle just have been started!"
exit
自动关闭ORACLE服务
vi Stop_ORA.sh
--------------------------------
echo "Begin to stop the oracle!"
sqlplus /nolog <<EOF
connect /as sysdba
shutdown immediate
exit
EOF
lsnrctl stop
echo "Oracle just have been stopped!"
exit
脚本编写完成后分别给这两个脚本执行权限
chmod a+x Start_ORA.sh
chmod a+x Stop_ORA.sh
将启动和关闭oracle脚本加到系统的开机自启动
vi /etc/rc.local
su - oracle -c "/home/oracle/Start_ORA.sh" #启动oracle
(责任编辑:IT)