Gets the process ID, and kill off

Directly on the case:

Example: Retrieving gerrit process

Method: $ ps -aux | grep nginx | ​​grep -v grep | awk '{print $ 2}' or $ ps -ef | grep nginx | ​​grep -v grep | awk '{print $ 2}'

 

Example: Retrieving gerrit process and kill off

Method: $ ps -aux | grep gerrit | grep -v grep | awk '{print "kill -9" $ 2}' | sh or $ ps -ef | grep gerrit | grep -v grep | awk '{print "kill - 9 "$ 2} '| sh

 

  • -ef show is System V style, and is aux BSD style.
  • COMMADN column if too long, aux truncates show, but will not ef

To sum up:
If you want CPU utilization and memory usage to see the process, you can use aux
If you want to see the process ID of the parent process and complete COMMAND command, you can use ef

Guess you like

Origin www.cnblogs.com/lyongyong/p/12074790.html
Recommended