shell close the specified process

For example, to turn off jupyter-notebook this process:

ps -ef | grip jupyter notebook | grep -v grep | cut -c 9-15 | xargs kill -9

Description: The pipe symbol "|" is used to separating the two commands, command pipe character to the left of the output will be used as input pipe symbol to the right of command. 

  "Ps -ef" View all processes
  "grep -v grep" is the process of removing contain the keyword "grep" in the process listed.
  "Cut -c 9-15" is the interception of the first nine character input lines to 15 characters, and this is precisely the process ID PID.
  "Xargs kill -9" xargs command is used in the preceding command output (PID) as a "kill -9" command parameter, and executes the command.
  "Kill -9" will be forced to kill the specified process, thus successfully cleared the same name process.

 

In addition, the process can be used for java jps (Java Virtual Machine Process Status Tool) command to view, correspondingly, close the command process:

jps | grep 'Elasticsearch' | awk -F ' ' '{print $1}' | xargs kill -9

Since the output is in the form of jps 'process ID, process name', so here empty Geqie awk command points, taking the first element (i.e., process), and then can be input to xargs.

reference:

shell kill the process method specified process name

Shell Find and shutdown process

Guess you like

Origin www.cnblogs.com/hellojesson/p/10942934.html