Reprinted from: http://www.blogjava.net/qileilove/archive/2014/11/07/419647.html
open terminal
cd /java/tomcat
#implement
bin/startup.sh #Start tomcat
bin / shutdown.sh #stop tomcat
tail -f logs/catalina.out #See the console output of tomcat;
#See if tomcat is already running
ps -ef |grep tomcat
#If there is, use kill;
kill -9 pid #pid is the corresponding process number
For example, the output of pe -ef |grep tomcat is as follows
sun 5144 1 0 10:21 pts/1 00:00:06 /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 number pid = 5144
kill -9 5144 can completely kill tomcat
First you have to know how to view the process :)
The two commands introduced above are used to view the current system user status. Let’s take a look at the process status, which is also the topic of this chapter. To monitor and control a process, you must first understand the current process status, and also It is necessary to view the current process, and the ps command is the most basic and also a very powerful process viewing command. Use this command to determine which processes are running and their running status, whether the process has ended, whether the process has zombies, and which processes have occupied it. More resources, etc. In short, most of the information can be obtained by executing this command.
The ps command is most commonly used to monitor the
work
of the background process, because the background process does not communicate with the standard input/output devices such as the screen keyboard, so if you need to detect its situation, you can use the ps command.
ps [options]
The command options are described below:
-e show all processes.
-f full format.
-h don't show headers.
-l long format.
-w wide output.
a shows all processes on the terminal, including those of other users.
r only shows running processes.
x shows processes that do not have a controlling terminal.
O[+|-] k1 [,[+|-] k2 [,…]] Displays the process list according to the multi-level sorting order specified by the shortcut keys in SHORT KEYS, k1, k2. For different formats of ps, there are default Order specification. These default orders can be overridden by user specification. The "+" character is optional, and the "-" character reverses the direction of the specified key.
The three most commonly used parameters are u, a, and x.