Explanation of several ways to run Tomcat under Linux

Explanation of several ways to run Tomcat under Linux

Starting and shutting down Tomcat under Linux

In Linux system, start and stop Tomcat using command operations.

Enter the bin directory under Tomcat

cd /java/tomcat/bin

Start Tomcat Command

./startup.sh

Stop Tomcat service command

./shutdown.sh

After executing tomcat ./shutdown.sh, although the tomcat service cannot be accessed normally, after running ps -ef | grep tomcat, it is found that the java process corresponding to tomcat is not destroyed when the web container is shut down, and zombie java processes exist. I looked up on the Internet and found that the cause of the zombie process may be the existence of a non-daemon thread (i.e. User Thread), and the JVM will not exit (when all threads in the JVM are daemon threads, the JVM can exit; if there is one or more non-daemon threads, the JVM will not exit). Use the following command to check whether the Tomcat process has ended:

ps -ef|grep tomcat

If similar information is displayed, it means that the Tomcat process has not ended.

gateway 14705 14703 12 08:29 pts/0 00:03:10 /www/websoft/java/java1/jdk1.7.0_25/jre/bin/java -Djava.util.logging.config.file=/www/websoft/tomcat1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -server -Xms1536m -Xmx1536m -Xss256k -XX:MaxPermSize=512m -XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=100 -XX:+UseAdaptiveSizePolicy -Djava.endorsed.dirs=/endorsed -classpath /www/websoft/tomcat1/bin/bootstrap.jar:/www/websoft/tomcat1/bin/tomcat-juli.jar -Dcatalina.base=/www/websoft/tomcat1 -Dcatalina.home=/www/websoft/tomcat1 -Djava.io.tmpdir=/www/websoft/tomcat1/temp org.apache.catalina.startup.Bootstrap start

At this point we can force the process to end (zombie process)

kill -9 14705

After the previous command is executed, check the Tomcat process again and you will find that Tomcat has completely stopped.

Several ways to run Tomcat on Linux

Start, shut down and error tracking of the tomcat service under Linux. After using PuTTy to remotely connect to the server, the tomcat service is usually started and shut down in the following ways:

Start the tomcat service

Method 1:

Start ./startup.sh

Method 2:

Start as a service nohup ./startup.sh &

Method 3:

Start the console dynamic output mode./catalina.sh ./catalina.sh run to dynamically display the console output information of the tomcat background, and exit and shut down the service after Ctrl+C

explain:

There is a disadvantage of starting Tomcat through method 1 and method 3. When the client connection is disconnected, the Tomcat service will stop immediately. Through method 2, it can run as a Linux service all the time.

The logs of Tomcat started by method 1 or method 2 will be written to the corresponding log files, but the output information and error conditions of the Tomcat console cannot be viewed dynamically.

Method 3 allows you to start the Tomcat service in console mode and directly view the background console output information when the program is running. You don't have to open the catalina.out log file every time, which makes it easier to track and view the background output information. Tomcat console information includes information output by log4j and System.out.println() .

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • How to configure multiple tomcats with Nginx load balancing under Linux
  • Linux centOS installation JDK and Tomcat tutorial
  • Installation of Tomcat9 and deployment of web projects under Linux CentOS
  • Tutorial on installing JDK Tomcat MySQL on Linux (remote access using Mac)
  • Detailed steps to download Tomcat and put it on Linux

<<:  ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: YES) Practical solution

>>:  Example usage of JavaScript tamper-proof object

Recommend

Solve the problem that Mysql5.7.17 fails to install and start under Windows

Install MySQL for the first time on your machine....

Summary of Vue component basics

Component Basics 1 Component Reuse Components are...

Is it easy to encapsulate a pop-up component using Vue3?

Table of contents Summary put first: 🌲🌲 Preface: ...

MySQL 5.7 deployment and remote access configuration under Linux

Preface: Recently I am going to team up with my p...

Detailed explanation of the execution process of JavaScript engine V8

Table of contents 1. V8 Source 2. V8 Service Targ...

In-depth analysis of Vue's responsive principle and bidirectional data

Understanding object.defineProperty to achieve re...

JavaScript implements displaying a drop-down box when the mouse passes over it

This article shares the specific code of JavaScri...

A brief introduction to MySQL functions

Table of contents 1. Mathematical functions 2. St...

Detailed explanation of the JVM series memory model

Table of contents 1. Memory model and runtime dat...

Exploring the Linux Kernel: The Secrets of Kconfig

Get a deep understanding of how the Linux configu...

How to add default time to a field in MySQL

Date type differences and uses MySQL has five dat...

Example code and method of storing arrays in mysql

In many cases, arrays are often used when writing...

HTML form tag usage learning tutorial

Forms in HTML can be used to collect various type...

How to get/calculate the offset of a page element using JavaScript

question By clicking a control, a floating layer ...