lost and found ( for me ? )

how to kill specific processes at once

Sometimes I mistakenly run many same processes like this
# ps aux | grep http_server_scapy.py
root     11765  2.1  0.1  82492 17876 pts/6    T    14:27   0:00 python ./http_server_scapy.py
root     11784  0.9  0.1  82196 17484 pts/6    T    14:27   0:00 python ./http_server_scapy.py
root     11837  4.2  0.1  82196 17408 pts/6    T    14:27   0:00 python ./http_server_scapy.py
root     11845  5.3  0.1  82056 17292 pts/6    T    14:27   0:00 python ./http_server_scapy.py
root     11851  0.0  0.1  82060 14508 pts/6    T    14:27   0:00 python ./http_server_scapy.py
root     11855  0.0  0.0  10368   944 pts/6    S+   14:27   0:00 grep --colour=auto http_server_scapy.py

Here’s an example of how to kill the same processes at once with shell script.

# cat kill_processes.sh
#!/bin/sh

proc=`ps aux | grep 'http_server_scapy.py' | grep -v grep | awk '{print $2}'`
for name in $proc
do
kill $name
done;

run the script to kill “python ./http_server_scapy.py”  processes at once.
# ./kill_processes.sh

# ps aux | grep http_server_scapy.py | grep -v grep
#

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.