Enable Tomcat to automatically join the system startup under Linux

zhaozj2021-02-16  84

Tomcat starts can be implemented with independent JSVC: JSVC is originally to download Commons-Daemon-1.0-alpha from http://jakarta.apache.org, but Tomcat has taken one, there is one in the Tomcat / bin directory. JSVC.TAR.GZ decompression, compile: #tar -xzvf jsvc.tar.gz #cd JSVC-SRC run #SH support / buildconf.sh #. / configure --with-java = / usr / java # make (Note: The JSVC source code with Tomcat-5.0.18 has a low-level error - less semicolons, which will cause compilation unsuccessful, can add this semicolon to the JSVC-SRC / Native directory of Tomcat yourself, there are two Script tomcat.sh and tomcat5.sh, can be used as a script that starts and stop Tomcat, I will be slightly modified, the files are as follows: Code: ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ #! / bin / sh # # # chkconfig: 345 87 13 # description: Tomcat daemon # processname: JSVC # pidfile: /var/run/jsvc.pid # config: # # source function library. . /etc/rc.d/init.d/functions # prog = tomcat # # small shell script to show how to start / stop tomcat using jsvc # if you want to have tomcat running on port 80 please modify the server.xml # File: # #

#

# Port = "80" minprocessors = "5" maxprocessors = "75"

# Enablelookups = "true" redirectport = "8443"

# Acceptcount = "10" debug = "0" connectionTIMEOUT = "60000" />

#

# You ued a development version of tomcat (apache tomcat / 4.1-dev)

#

# Adapt the folload lines to your configuration

# Set your own parameters

Java_Home = / usr / local / j2sdk1.4.2-04 Catalina_Home = / usr / local / jakarta-tomcat-5.0.19 daemon_home = $ catalina_home / bin # need to set a no permission in the system

# 用户 用户 来, this is more secure

Tomcat_user = Tomcat5

TMP_DIR = / VAR / TMP

Catalina_opts =

Classpath = /

$ Java_home / lib / Tools.jar: /

$ Catalina_home / bin / commons-daemon.jar: /

$ Catalina_home / bin / bootstrap.jar

START () {

echo -n $ "Starting $ PROG:" #

# Start Tomcat

#

$ Daemon_Home / 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

#

# T Get a verbose jvm

# -verbose /

# TO GET A Debug of JSVC.

# -debug /

RetVal = $?

[$ RETVAL = 0] && touch / var / lock / subsys / jsvc

[$ RETVAL = 0] && echo_success || echo_failure

echo

Return $ RetVal

}

STOP () {

Echo -n $ "Stopping $ PROG:"

#

# 帖子 t t

#

PID = `cat / var / run / jsvc.pid`

Kill $ PID

RetVal = $?

[$ RETVAL = 0] && RM / VAR / LOCK / SUBSYS / JSVC

[$ RETVAL = 0] && echo_success || echo_failure

echo

Return $ RetVal

}

Case "$ 1" in

START)

Start

;

STOP)

STOP

;

Restart | Reload)

STOP

Start

;

*)

Echo "Usage $ 0 START / STOP"

EXIT 1 ;;

ESAC

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 00 List Look at whether the system has Tomcat startup file #ckhconfig --List, you can automatically start with the system service with the system. This script will start from the Runlevel 3/4/5. Note that this script is created for Tomcat5. If you use Tomcat4, you will need to modify it on another Tomcat.sh.

转载请注明原文地址:https://www.9cbs.com/read-14130.html

New Post(0)