Linux self-booting tomcat

Source: Internet
Author: User

The first way

1. Modify the script file rc.local:vim/etc/rc.d/rc.local

This script is a user-defined start-up program that can add scripts or scripts that you want to execute after the system starts.

2. Add the following:

Export java_home=/usr/local/jdk1.8.0_171

/usr/local/apache-tomcat-7.0.88/bin/ start

3.esc exit Edit,: Wq Save changes

4. Change the rc.local to executable

chmod 777/etc/rc.d/rc.local

The second way:

    1. Vi/etc/init.d/tomcat
#!/bin/sh  345  # Description:auto-starts tomcat  /etc/init.d/  TOMCATD  # Tomcat Auto-start  # Source function library.   /etc/init.d/Functions  # Source Networking configuration.   /etc/sysconfig/Network  RETVAL=0  export java_home=/usr/local/jdk1.8.0_171

export jre_home=/usr/local/jdk1.8.0_171/JRE
Export Catalina_home=/usr/local/apache-tomcat-7.0.88Export Catalina_base=/usr/local/apache-tomcat-7.0.88start () {if[-F $CATALINA _home/bin/]; Then echo $"Starting Tomcat"$CATALINA _home/bin/ RETVAL=$?Echo"OK"return$RETVAL fi} Stop () {if[-F $CATALINA _home/bin/]; Then echo $"Stopping Tomcat"$CATALINA _home/bin/ RETVAL=$?Sleep1PS-FWWU Root | grep tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs kill-9Echo"OK"# [$RETVAL-eq 0] && rm-f/var/lock/...              return$RETVAL fi} Case"$"In start) start;                                                     stop) stop;; Restart) echo $"Restaring Tomcat"           $0Stop Sleep1           $0start;; *) echo $"Usage: $ {Start|stop|restart}"Exit1          ;; ESAC Exit $RETVAL

Set permissions:

chmod 755/etc/init.d/tomcat

Set Boot start service
    1. sudo chkconfig tomcat on

Start, stop Tomcat

    1. Service Tomcat start #或者/etc/init.d/tomcat start
    2. Service Tomcat stop #或者/etc/init.d/tomcat stop

Linux self-booting tomcat

Related Article

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: 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.