tomcat start stop 脚本

创建文件tomcat,文件内容如下


[root@node1 ~]# vi /etc/init.d/tomcat
#!/bin/sh
##############################################
#Startup script for Tomcat on Linux
#filename tomcat.sh
#Make sure the java and the tomcat installation path has been added to the PATH
 
################################################

JAVA_HOME=/usr/java/jdk1.5.0_15
export JAVA_HOME


CATALINA_HOME=/usr/local/tomcat-5.5.28
 
start_tomcat=${CATALINAHOME}/bin/startup.sh                    
stop_tomcat=${CATALINAHOME}/bin/shutdown.sh
 
start() {                                           
        echo -n "Starting tomcat: "
        ${start_tomcat}
        echo "tomcat start ok."
}
stop() {
        echo -n "Shutting down tomcat: "
        ${stop_tomcat}
        echo "tomcat stop ok."
}
 
# See how we were called

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        sleep 1
        start
        ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
esac
 
exit 0

#######################


使用以上的脚本就可以使用 脚本  tomcat start |stop | restart 来启动tomcat, 如果把tomcat文件拷贝到/etc/init.d目录下就可以使用 

service tomcat start    #启动tomcat

service tomcat stop    #关闭tomcat


当使用heartbeat来做双机热备时, 可以使用该脚本, 在heartbeat的配置haresources 文件中配置tomcat即可

你可能感兴趣的:(大众软件)