建立檔案名為oracle
[root@stark init.d]# pwd
/etc/init.d
[root@stark init.d]# touch oracle
向oracle中添加下列内容
#!/bin/bash
# chkconfig: 35 95 1
# description: init script. to start/stop oracle database 10g, TNS listener, EMS
# match these values to your environment:
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/10.2
export ORACLE_TERM=xterm
export PATH=/home$ORACLE_HOME/bin:$PATH:.
export NLS_LANG=American_America.AL32UTF8
export ORACLE_SID=stark
export DISPLAY=localhost:0
export ORACLE_USER=oracle
case $1 in
start)
su - "$ORACLE_USER"<<stark
lsnrctl start
sqlplus /nolog<<jadeshow
connect / as sysdba
startup
jadeshow
stark
;;
stop)
lsnrctl stop
shutdown immediate
*)
echo "Usage: $0 {start|stop}"
esac
修改權限,使得oracle具有可執行權限
[root@stark init.d]# chmod a+x oracle
添加oracle到系統服務并且開機啟動
[root@stark init.d]# chkconfig add oracle
[root@stark init.d]# chkconfig oracle on
本文轉自 珏石頭 51CTO部落格,原文連結:http://blog.51cto.com/gavinshaw/917882,如需轉載請自行聯系原作者