Linux Tomcat Service Registration __linux

Source: Internet
Author: User

1. New file:/ect/init.d/tomcat

2, edit the contents of the file:

#!/bin/sh #chkconfig: 2345 description:starts and Stops the Tomcat daemon. #by kanaka10 ############################################## #startup script for Tomcat on Linux #filename/etc/init.d/to MCAT java_home=/usr/java/jdk1.7.0_80 catalina_home=/apache-tomcat-7.0.72 Export java_home export CATALINA_HOME ###### ######################################### start_tomcat= $CATALINA _home/bin/startup.sh stop_tomcat= $CATALINA _home/ 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."} Status () {PS ax--width=1000 | grep [O]rg.apache.catalina.startup.bootstrap] | awk ' {printf $ '} ' | WC | awk ' {print $} ' >/tmp/tomcat_process_count.txt Read line </tmp/tomcat_process_count.txt if [$line-gt 0]; Then Echo-n "Tomcat (PID) PS Ax--width=1000 | grep "[O]rg.apache.catalina.startup.bootstrap" |
                                                  
awk ' {printf '} ' echo ' is running ' else echo ' tomcat ' running '.
  Case "in Start" start;;
  stop) stop;;
  status) status;;
  Restart) stop sleep start;;
 *) echo "Usage: $ {start|stop|restart|status}" Esac

3, give file execution permission: chmod a+x Tomcat

4. Add Service: Chkconfig--add Tomcat

5, Start services: Service Tomcat start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.