linux 下注冊tomcat

  1. 1.在/etc/rc.d/init.d中建腳本tomcat.  
  2. chmod +x tomcatd  
  3. 2.chkconfig --add tomcat就可以用service tomcat start/stop/rstart了  
  4. 附:腳本 
  5. Ruby代碼   
  6. #!/bin/sh   
  7. #   
  8. # Startup script for Tomcat, the Apache Servlet Engine   
  9. #   
  10. # chkconfig: 345 80 20   
  11. # description: Tomcat is the Apache Servlet Engine   
  12. # processname: tomcat   
  13. # pidfile: /var/run/tomcat.pid   
  14. #   
  15. # Mike Millson <mmillson@meritonlinesystems.com>;   
  16. #   
  17. # version 1.02 - Clear work directory on shutdown per John Turner suggestion.   
  18. # version 1.01 - Cross between Red Hat Tomcat RPM and Chris Bush scripts   
  19.    
  20. # Tomcat name :)   
  21. TOMCAT_PROG=tomcat   
  22.    
  23. # if TOMCAT_USER is not set, use tomcat like Apache HTTP server   
  24. if [ -z "$TOMCAT_USER" ]; then   
  25. TOMCAT_USER="root"   
  26. fi   
  27.    
  28. RETVAL=0   
  29.    
  30. # start and stop functions   
  31. start() {   
  32.     echo -n "Starting tomcat: "   
  33.    
  34.     chown -R $TOMCAT_USER:$TOMCAT_USER /usr/local/tomcat/*      
  35.     su -l $TOMCAT_USER -c '/usr/local/tomcat/bin/startup.sh'   
  36.     RETVAL=$?   
  37.     echo   
  38.     [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat   
  39.     return $RETVAL   
  40. }   
  41.    
  42. stop() {   
  43.     echo -n "Stopping tomcat: "   
  44.     su -l $TOMCAT_USER -c '/usr/local/tomcat/bin/shutdown.sh'   
  45.     RETVAL=$?   
  46.     echo   
  47.     [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid      
  48.     rm -rf /usr/local/tomcat/work/*   
  49. }   
  50.    
  51. # See how we were called.   
  52. case "$1" in   
  53.   start)   
  54.         start   
  55.         ;;   
  56.   stop)   
  57.         stop   
  58.         ;;   
  59.   restart)   
  60.         stop   
  61.         # Ugly hack   
  62.         # We should really make sure tomcat   
  63.         # is stopped before leaving stop   
  64.         sleep 2          
  65.         start   
  66.         ;;   
  67.   *)   
  68.         echo "Usage: $0 {start|stop|restart}"   
  69.         exit 1   
  70. esac   
  71.    
  72. exit $RETVAL   

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章