设置Tomcat Jboss Oracle Mysql Linux自启动服务实例

boxifeng 2010-07-01

关于自启动服务怎么设置请看另一篇文章:

设置Linux自启动服务http://just4java.iteye.com/blog/474392

下面附的是相关的运行脚本和服务启动脚本

·Tomcat

1运行脚本自带/usr/local/tomcat/bin/startup.sh

2服务启动脚本

#!/bin/sh 
# whoami 
# root 
# chkconfig: 2345 65 37 
# description: starts tomcat6 
export JAVA_HOME=/usr/local/jdk1.5.0_18 
export CATALINA_HOME=/usr/local/tomcat 
export CATALINA_BASE=/usr/local/tomcat 
CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jar 
case "$1" in 
start) 
   echo "Starting tomcat6..." 
   $CATALINA_BASE/bin/startup.sh 
   ;; 
stop) 
   echo "Stopping tomcat6..." 
   $CATALINA_BASE/bin/shutdown.sh 
   ;; 
*) 
   echo "Usage tomcat.sh start/stop" 
   exit 1;; 
esac

·Jboss

1运行脚本自带/usr/local/jboss/bin/run.sh

2服务启动脚本

#!/bin/bash
# chkconfig: 2345 66 36
# description: starts jboss
export JAVA_HOME=/usr/local/jdk1.5.0_18
case "$1" in
start)
  echo -n "Starting jboss: "
  #start
  "/usr/local/jboss/bin/run.sh" &
  echo
;;

stop)
  echo -n "shutting down jboss: "
  #stop
  "/usr/local/jboss/bin/shutdown.sh"
  echo
;;

restart)
  echo -n "restarting jboss: "
  $0 stop
  $0 start
  echo
;;
*)
echo "usage: jboss { start | stop | restart }"
exit 1

esac
exit 0

·Oracle

1运行脚本

start_db.sh

#!/bin/sh
export ORACLE_SID=dbname
lsnrctl start
sqlplus "/as sysdba"<<EOF
startup

shutdown_db.sh

#!/bin/sh
export ORACLE_SID=dbname
lsnrctl stop
sqlplus "/as sysdba"<<EOF
shutdown immediate

2服务启动脚本

#!/bin/bash
# chkconfig: 2345 66 36
# description: starts the oracle dabase deamons
case "$1" in
start)
  echo -n "Starting oracle10g: "
  #start
  su - oracle -c "/home/oracle/script/start_db.sh"
  echo
;;
stop)
  echo -n "shutting down oracle10g: "
  #stop
  su - oracle -c "/home/oracle/script/shutdown_db.sh"
  echo
;;
restart)
  echo -n "restarting oracle10g: "
  $0 stop
  $0 start
  echo
;;
*)
echo "usage: oracle10g { start | stop | restart }"
exit 1
esac
exit 0

·Mysql

#>cp/usr/local/mysql/support-files/mysql.server/etc/rc.d/init.d

#>mvmysql.servermysql

相关推荐

doctorvian / 0评论 2017-12-06