码迷,mamicode.com
首页 > 其他好文 > 详细

tomcat 开机自启

时间:2016-07-23 16:30:37      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

vim /etc/init.d/tomcat
 1 #!/bin/bash
 2 
 3   
 4 #match these values to your environment
 5 ####################################################################################
 6 export JAVA_HOME="/usr/local/jdk1.7.0_65"
 7 export CATALINA_HOME="/usr/local/tomcat7.0.54"
 8 export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/jre/lib/rt.jar
 9 export PATH=$PATH:$JAVA_HOME/bin
10 export JAVA_OPTS="-server -Xms512m -Xmx512m"
11 ####################################################################################
12 getPID() {
13 PID=$(ps -ef | grep -v grep | grep "${CATALINA_HOME}/conf/logging.properties" | awk {print $2})
14 }
15   
16 start() {
17         getPID
18         if [[ "${PID}X" != "X" ]]; then
19             echo "tomcat is already running"
20         else
21             echo "tomcat is starting"
22             ${CATALINA_HOME}/bin/catalina.sh start
23             tailf ${CATALINA_HOME}/logs/catalina.out
24         fi
25 }
26   
27 stop() {
28         getPID
29         if [[ "${PID}X" == "X" ]]; then
30             echo "tomcat is not running"
31         else
32             kill -9 $PID
33             echo "tomcat is stop done"
34         fi
35 }
36   
37 restart() {
38         getPID
39         if [[ "${PID}X" == "X" ]]; then
40             echo "tomcat is not running,and will be start"
41             ${CATALINA_HOME}/bin/catalina.sh start
42             echo "tomcat is starting"
43         else
44             kill -9 $PID
45             echo "tomcat is stop"
46             ${CATALINA_HOME}/bin/catalina.sh start
47             echo "tomcat is starting"
48             tailf ${CATALINA_HOME}/logs/catalina.out
49         fi
50 }
51   
52 status() {
53         getPID
54         if [[ "${PID}X" == "X" ]]; then
55             echo "tomcat is not running!"
56         else
57             echo "tomcat is running!"
58         fi
59 }
60   
61 case $1 in
62         start   )
63                 start
64                 ;;
65         stop    )
66                 stop
67                 ;;
68         restart )
69                 restart
70                 ;;
71         status  )
72                 status
73                 ;;
74         *       )
75                 echo $"Usage: $0 {start|stop|restart|status}"
76                 exit 2
77                 ;;
78 esac
update-rc.d tomcat defaults

 

tomcat 开机自启

标签:

原文地址:http://www.cnblogs.com/MDK-L/p/5695292.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!