환경설정을 맞추어 아래의 스크립트를 작성한다.
#!/bin/sh
# 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=/usr/u01/app/oracle
export ORACLE_HOME=/usr/u01/app/oracle/product/10.2.0.1
export ORACLE_TERM=xterm
export PATH=/home/oracle/bin:$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
export DISPLAY=<your ip address>:0
export ORACLE_USER=oracle
# see how we are called:
case $1 in
start)
su - $ORACLE_USER <<EOO
lsnrctl start
sqlplus /nolog<<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
EOO
;;
stop)
su - $ORACLE_USER <<EOO
lsnrctl stop
sqlplus /nolog<<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
EOO
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac