---
title: "Oracle 10g 自启动脚本"
author: "squll369"
date: "2011-07-13T23:59:34Z"
tags: []
categories: ["数据库"]
slug: "oracle-10g"
draft: false
lastmod: "2011-07-13T23:59:34Z"
id: 1123897
url: "https://squll369.iteye.com/blog/1123897"
---

linux下Oracle自启动脚本, 记录如下：

 

```
#!/bin/bash
#
#name:/etc/init.d/oracle10ginit
#chkconfig:2345 99 91
#description:Start and Stop ORACLE 10g
start(){
        #Start TNS
 echo "Starting TNS......"
 su - oracle -c "lsnrctl start"
        sleep 5
 echo "TNS started successfully" 

        #Start Oracle Instance
 echo "Starting Oracle Instance......"
 su - oracle -c "echo \"
   CONN SYS/password AS SYSDBA
   STARTUP
   exit \"|sqlplus /NOLOG"
 sleep 5
 echo "Oracle Instance started successfully"

 #start enterprise manager
        echo "Starting Enterprise Manager"
 su - oracle -c "emctl start dbconsole"
 sleep 5
 echo "Enterprise Manager started successfully"

 #Start isqlplus
 echo "Starting isqlplus"
 su - oracle -c "isqlplusctl start"
 sleep 5
        echo "isqlplus started successfully"
}

stop(){
 #shutdown DB Instance
 echo "Shutdown Oracle DB Instance"
 su - oracle -c "echo \"
   CONN SYS/password AS SYSDBA
   SHUTDOWN immediate
   exit \"|sqlplus /NOLOG"
 sleep 5
 echo "DB Instance shutdown successfully"

 #stop TNS
 echo "STOP TNS"
 su - oracle -c "lsnrctl stop"
 sleep 5
 echo "TNS stop successfully"

 #stop enterprise manager
 echo "Stop Emterprise Manager"
 su - oracle -c "emctl stop dbconsole"
 sleep 5
 echo "enterprise manager stop successfully"

 #stop isqlplus
 echo "Stop isqlplus"
 su - oracle -c "isqlplusctl stop"
 sleep 5
 echo "isqlplus stop successfully"
}

case "$1" in
start)
 start
 ;;
stop)
 stop
 ;;
*)
 echo "Usage:oracle10ginit[start|stop]" 
 ;;

esac
```