LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1101|回复: 0

ubuntu下面使用jsvc启动tomcat问题,请高手帮忙

[复制链接]
发表于 2006-6-5 19:51:45 | 显示全部楼层 |阅读模式
在tomcat使用jsvc实现自动启动遇到了一些问题,虽然jsvc可以运行,但是不能启动tomcat,(tomcat的安装目录属于tomcat用户和tomcat组),不知道是什么原因么??
  1. root@Lee-ubuntu:/etc/init.d# ./tomcat5.sh
  2. Usage tomcat.sh start/stop
  3. root@Lee-ubuntu:/etc/init.d# ./tomcat5.sh  start
  4. root@Lee-ubuntu:/etc/init.d#
  5. 这里什么也不输出,但是jsvc进程确实已经运行了。
复制代码
但是使用tomcat5运行就没有什么问题。
  1. root@Lee-ubuntu:/etc/init.d# ./tomcat5  start
  2. Starting Tomcat service: Using CATALINA_BASE:   /usr/share/tomcat5
  3. Using CATALINA_HOME:   /usr/share/tomcat5
  4. Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
  5. Using JRE_HOME:       /usr/lib/jvm/java-1.5.0-sun-1.5.0.06
  6. root@Lee-ubuntu:/etc/init.d#
复制代码
还有一个问题就是tomcat5.sh不能被 sysv-rc-conf识别,所以不知道怎么去实现自动运行,我的shell设计水平有限,现在我有两个文件。你们谁能帮我把tomcat.sh按照 tomcat重新写一边哦? 就是些一个tomcat脚本。实现使用jsvc启动tomcat. 谢谢了~~

文件tomcat.sh
  1. #!/bin/sh
  2. 1##############################################################################
  3. #
  4. #   Copyright 2004 The Apache Software Foundation.
  5. #
  6. #   Licensed under the Apache License, Version 2.0 (the "License");
  7. #   you may not use this file except in compliance with the License.
  8. #   You may obtain a copy of the License at
  9. #
  10. #       >>http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. #   Unless required by applicable law or agreed to in writing, software
  13. #   distributed under the License is distributed on an "AS IS" BASIS,
  14. #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. #   See the License for the specific language governing permissions and
  16. #   limitations under the License.
  17. ##############################################################################
  18. #
  19. # Small shell script to show how to start/stop Tomcat using jsvc
  20. # If you want to have Tomcat running on port 80 please modify the server.xml
  21. # file:
  22. #
  23. #    <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
  24. #    <Connector className="org.apache.catalina.connector.http.HttpConnector"
  25. #               port="80" minProcessors="5" maxProcessors="75"
  26. #               enableLookups="true" redirectPort="8443"
  27. #               acceptCount="10" debug="0" connectionTimeout="60000"/>
  28. #
  29. # That is for Tomcat-5.0.x (Apache Tomcat/5.0)
  30. #
  31. # Adapt the following lines to your configuration
  32. JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.06
  33. CATALINA_HOME=/usr/share/tomcat5
  34. DAEMON_HOME=/usr/share/tomcat5
  35. TOMCAT_USER=tomcat5
  36. TMP_DIR=/var/tmp
  37. CATALINA_OPTS=
  38. CLASSPATH=
  39. $JAVA_HOME/lib/tools.jar:
  40. $CATALINA_HOME/bin/commons-daemon.jar:
  41. $CATALINA_HOME/bin/bootstrap.jar
  42. case "$1" in start) # # Start Tomcat # $DAEMON_HOME/bin/jsvc-src/jsvc -user $TOMCAT_USER -home $JAVA_HOME -Dcatalina.home=$CATALINA_HOME -Djava.io.tmpdir=$TMP_DIR -outfile $CATALINA_HOME/logs/catalina.out -errfile '&1' $CATALINA_OPTS -cp $CLASSPATH org.apache.catalina.startup.Bootstrap # # To get a verbose JVM #-verbose # To get a debug of jsvc. #-debug ;;
  43. stop) # # Stop Tomcat # PID=`cat /var/run/jsvc.pid` kill $PID ;;
  44. *) echo "Usage tomcat.sh start/stop" exit 1;; esac
复制代码

下面是tomcat文件
  1. # This is the init script for starting up the
  2. #  Jakarta Tomcat server
  3. #
  4. # chkconfig: 345 91 10
  5. # description: Starts and stops the Tomcat daemon.
  6. #
  7. # Source function library. #. /etc/rc.d/init.d/functions
  8. # Get config. #. /etc/sysconfig/network
  9. # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 0
  10. tomcat=/usr/share/tomcat5 startup=$tomcat/bin/startup.sh shutdown=$tomcat/bin/shutdown.sh export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.06 export CATALINA_HOME=/usr/share/tomcat5
  11. start(){ echo -n $"Starting Tomcat service: " $startup RETVAL=$? echo }
  12. stop(){ action $"Stopping Tomcat service: " $shutdown RETVAL=$? echo }
  13. status(){ numproc=`ps -ef | grep catalina | grep -v "grep catalina" | wc -l` if [ $numproc -gt 0 ]; then echo "Tomcat is running..." else echo "Tomcat is stopped..." fi }
  14. restart(){ stop sleep 5 start }
  15. # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|status|restart}" exit 1 esac
  16. exit 0
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表