Run level shell script to start Oracle 10g services on RedHat Enterprise Linux (RHAS 4)
Posted in Script
#!/bin/bash # # Run level script to start Oracle 10g services on RedHat Enterprise Linux (RHAS 4) # Script should work on other UNIX like oses :) # ------------------------------------------------------------------------- # Copyright (c) 2006 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # Comment/suggestion: <vivek at nixCraft DOT com> # ------------------------------------------------------------------------- # chkconfig: 345 91 19 # description: Startup/Shutdown Oracle service OUSER="oracle" OPATH="/home/oracle/oracle/product/10.2.0/db_1" # check Oracle db status function chkdb_status() { # set username SUSER="scott" # set password SPASS="123456" sqlplus -s /nolog > /dev/null 2>&1 <<EOF whenever sqlerror exit failure connect $SUSER/$SPASS exit success EOF if [ $? -ne 0 ]; then echo "Connection failed : DB is down" exit 1 else echo "Connection succeeded : DB is up" fi } case "$1" in start) echo "*** Starting Oracle *** " su - $OUSER -c "$OPATH/bin/lsnrctl start" su - $OUSER -c "$OPATH/bin/dbstart" ;; stop) echo "*** Stopping Oracle *** " su - $OUSER -c "$OPATH/bin/lsnrctl stop" su - $OUSER -c "$OPATH/bin/dbshut" ;; restart) $0 stop $1 start ;; isqlstart) echo "*** Starting Oracle iSQL Plus *** " su - $OUSER -c "$OPATH/bin/isqlplusctl start" echo "*** Note: You can access service at url: http://$(hostname):5560/isqlplus" ;; isqlstop) echo "*** Stopping Oracle iSQL Plus *** " su - $OUSER -c "$OPATH/bin/isqlplusctl stop" ;; emstart) echo "*** Starting Oracle Enterprise Manager 10g Database Control ***" su - $OUSER -c "$OPATH/bin/emctl start dbconsole" echo "*** Note: You can access service at url: http://$(hostname):1158/em" ;; emstop) echo "*** Stopping Oracle Enterprise Manager 10g Database Control ***" su - $OUSER -c "$OPATH/bin/emctl stop dbconsole" ;; status) echo "*** Oracle database status ***" chkdb_status ;; *) echo $"Usage: $0 {start|stop|isqlstart|isqlstop|emstart|emstop}" exit 1 esac exit 0
Download - Email this to a friend - Printable version
Discussion on This Shell Script:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: enterprise linux, linux restart oracle, linux start oracle, linux stop oracle, opath, oracle, oracle 10g, oracle db, oracle product, oracle service, ouser, rhas, shell script, sqlplus s, startup shutdown ~ Last updated on: April 10, 2008



Thank you … that tutorial has me very helped.