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

A brief discussion on MySQL temporary tables and derived tables

About derived tables When the main query contains...

Sample code for seamless scrolling with flex layout

This article mainly introduces the sample code of...

Install Tomcat on Linux system and configure Service startup and shutdown

Configure service startup and shutdown in Linux s...

Example of writing mobile H5 to invoke APP (IOS, Android)

iOS 1. URL scheme This solution is basically for ...

Detailed installation process and basic usage of MySQL under Windows

Table of contents 1. Download MySQL 2. Install My...

How to enable or disable SSH for a specific user or user group in Linux

Due to your company standards, you may only allow...

Use PS to create an xhtml+css website homepage in two minutes

There are too many articles about xhtml+css websi...

Detailed explanation of the difference between tinyint and int in MySQL

Question: What is the difference between int(1) a...

How to use VLAN tagged Ethernet card in CentOS/RHEL system

In some scenarios, we want to assign multiple IPs...

CSS pseudo-element::marker detailed explanation

This article will introduce an interesting pseudo...

The connection between JavaScript constructors and prototypes

Table of contents 1. Constructors and prototypes ...

CSS horizontal progress bar and vertical progress bar implementation code

Sometimes it’s nice to see some nice scroll bar e...