After setting the linux server for one afternoon, tomcat was crashed. I checked the cause on the Internet and found that the process was occupied, so I began to kill the tomcat process.
First, you must know how to view the process :)
The two commands described above are used to view the current system user situation. Here we will look at the process situation, which is also the topic of this chapter. to monitor and control the process, you must first understand the situation of the current process.
You need to view the current process, and the ps command is the most basic and very powerful process view command. you can use this command to determine which processes are running and running, whether the processes are completed,
There are no botnets in processes, which occupy too much resources, etc. In short, most of the information can be obtained by executing this command.
The most common ps command is used to monitor the working conditions of background processes, because background processes do not communicate with standard input/output devices such as the screen keyboard, so if you need to detect the situation, you can use the ps command.
Ps [Option]
The following describes the Command Options:
-E: displays all processes.
-F full format.
-H does not display the title.
-L long format.
-W width output.
A displays all processes on the terminal, including those of other users.
R only displays running processes.
X displays the processes without control terminals.
O [+ |-] k1 [, [+ |-] k2 [,…] Based on the number of keykeys specified in short keys, k1, and k2
The process list is displayed in a sorted order. The default sequence is specified for different ps formats.
The order of recognition can be overwritten by the user's designation. The "+" character is optional, and the "-" character is reversed to specify the direction of the key.
The three most common parameters are u, a, and x.Then, perform operations on the Tomcat process: Start, shut down, and kill the Tomcat process in Linux.
Open Terminal
Cd/java/tomcat
# Execution
Bin/startup. Sh # start Tomcat
Bin/shutdown. Sh # Stop Tomcat
Tail-F logs/Catalina. Out # view Tomcat console output;
# Check whether Tomcat is running
PS-Ef | grep Tomcat
# If yes, use kill;
Kill-9 pid # PID is the corresponding process number
For example, the pe-Ef | grep Tomcat output is as follows:
Sun 5144 1 0 00:00:06 pts/1/Java/JDK/bin/Java
-Djava. util. Logging. Manager = org. Apache. Juli. classloaderlogmanager
-Djava. endorsed. dirs =/Java/tomcat/common/endorsed-classpath
:/Java/tomcat/bin/Bootstrap. jar:/Java/tomcat/bin/commons-logging-api.jar
-Dcatalina. base =/Java/tomcat-dcatalina. Home =/Java/tomcat
-Djava. Io. tmpdir =/Java/tomcat/temp
Org. Apache. Catalina. startup. Bootstrap start
Then 5144 is the process ID pid = 5144
Kill-9 5144 to completely kill Tomcat