Killing a number of processes

When I enter the ps -ef | grep sharatds, I get a list of processes.

sharatds 13164 13163  0 20:53 pts/2    00:00:00 [bt.C.256] <defunct>
sharatds 13165 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13199 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13233 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13267 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13301 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13335 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13369 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13403 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13437 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13471 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13505 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13539 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13573 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13607 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13641 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13675 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13709 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13743 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13777 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13811 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13845 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13879 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>
sharatds 13913 13163  0 20:53 pts/2    00:00:00 [rsh] <defunct>

I want to kill all processes that have the last column as non-existent.

Can someone help me with a script?

+3
source share
2 answers

This will do:

ps -ef | grep sharatds | awk '{print $2}' | xargs kill
+7
source

Usually I do something like this:

kill $(ps -ef |grep sharatds|awk '{print $2}')

Edit: Wait! These are nonexistent processes. They are already dead and can no longer be killed! The parent process will have to start wait()in order to read their states so that they can be cleared and deleted from the process table.

+4
source

Source: https://habr.com/ru/post/1779912/


All Articles