Find the matching process and close the linux ps -ef

Delete process called udpserver process.

kill -9 $ (ps -ef | grep udpserver | grep java | awk '{print $ 2}').

1. Get the process number through the process name:

ps -ef | grep udpserver | awk '{print $ 2}'

Results: The return of two processes, one of which is grep process.

2. increase the filtering conditions

ps -ef | grep udpserver | grep java | awk '{print $ 2}'

Result: return to a process for the process udpserver. (According to the need to increase more filters)

4.awk

awk ... command is a print column, the column is pid ps -e command output, $ 2 for the specified column.

4. Delete the process ID

kill -9

NOTE: Use kill -9 $ (ps -ef | grep udpserver | grep java | awk '{print $ 2}'), a plurality of processes with the same name can kill process name.

Guess you like

Origin www.cnblogs.com/doude/p/12225781.html