Tag Archives: kill

Kill Tomcat process in windows and Linux environment (solve the problem of other ports being occupied)

Killing process in Windows

1. First of all, find out the PID of the process number that occupies port 8080 ( tomcat, the default is port 8080. If you modify the monitoring port of tomcat, please write in your Tomcat port number or other port numbers ) what I query is port 7777

​netstat -ano | findstr 8080

The last column of the command output indicates the number of the process occupying port 7777, assuming 10976

2. Kill the process, thus freeing the port

taskkill /f /pid 10976 

 

 

Closing Tomcat process under Linux operating system

1. See if Tomcat is already running

ps -ef |grep tomcat 

If Tomcat is running, the result will be similar to the following:

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

From the above output information, we can know that the process number of Tomcat execution is 5144.

2. Execute the following command to kill the 5144 process

pid = 5144 kill -9 5144 

3. Get the occupancy of a certain port (for example, get the occupancy of port 5533 below)

sudo lsof -i :5533

The result is as follows: you can see that the process number is 2960, we just need to kill it.

COMMAND  PID        USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    2960 zhengcanrui   55u  IPv6 0xb866409b03202701      0t0  TCP *:5533 (LISTEN)

Kill process command:

kill -9 2960

MySQL error 1205 (HY000): lock wait timeout exceeded; try restarting transaction



after querying the current thread, it was found that multiple threads were running at the same time…

to view all currently running transactions:

SELECT * FROM information_schema.INNODB_TRX;


you can find three transactions all running at the same time… So you can find the direct cause of the error reported by the shopkeeper here is:
before the stored procedure (which opened the transaction) ran for half a day, MySQL was manually closed without any response… Didn’t make it commit… And the subsequent deletion of data in the same transaction creates a transaction lock…
The fundamental reason is that MySQL USES the Innodb engine by default, and the default parameter of Innodb: innodb_lock_wait_timeout, which sets the maximum time for transactions to wait for acquiring resources (default 50s). Once the maximum time is exceeded, it will report errors such as questions without obtaining resources.
Well, now that the cause of the error has been identified, there are three solutions:
Find the thread of the current transaction, kill the thread; Enlarge this parameter: innodb_lock_wait_TIMEOUT wait time; Optimize stored procedures.
Here the shopkeeper takes the first approach, killing the redundant threads and then checking all the currently running transactions again:

find something strange?The killed thread Number 10 is still working??Its current state is “ROLLING BACK,” which means that the transaction that was killed a while ago has been in a rollback state. So the shopkeeper continued to look up materials and found that such a situation occurred because although the kill command was triggered, it took a long time to terminate the kill logic, and it was also affected by IO resources. Therefore, rollback occurred even though the kill was executed.
Solutions:
One is to wait for it to roll back; Another is to restart the MySQL, but restart MySQL, the transaction will roll back, so in general is actually etc. It can be rolled back end 😂!

waited for about seven or eight minutes before everything was cleared, and all transactions were over:

and then delete again:

Forced shutdown of VMware wrokstation error (failed to get exclusive lock on the configuration file —)

today I accidentally shut down the VMware. Exe process in the process. It doesn’t matter if I shut it down.

said that a running process was using the “configuration” file and was unable to obtain the lock for the configuration file, causing a failure.

know the error, we can solve the problem, there is a process using this file, then we go to the process to look, of course, the first thing we think of is, is the virtual machine process. Three virtual machine processes were actually found in the process manager,

vmware – usbarbibrator. Exe

vmware – unity – helper. Exe

vmware – VMX. Exe

my first instinct was vmware. Exe,kill it, really, the virtual machine is up.

Batch delete process

automation test, up a lot of Google pages, delete trouble, in the command line to execute, delete all at once, hard

ps -ef | grep google | awk '{print $2}' | xargs kill -9