Sometimes I have a desire to kill many processes using just one line of my BASH console. All this stuff like finding out PIDs from
ps commands, killing them manually makes me suffer!
Deal, it has to be a shell-script in order to automate it!
First of all we got to create an empty file to put commands into it, let us do it:
Once the file is created we have to make it executable, easily:
chmod +x ./kill-all.sh
Now we have a script that could be run and we got to fill it with some helpful instructions:
#!/bin/bash # Defining a proc name proc_name=$1 # Clearing stdout clear # Performing killing ps -aux | grep "$proc_name" | grep -v grep | cut -c 10-15 | xargs sudo kill -9
It's done! Now if you are going to kill many processes with same name you just need to run this quite simple instruction:
It will lead you to close all the processes with name
Thanks for reading this article! You may follow me in order to be updated with most new articles from my side.
As usual if you have anything just let me know about it in the comments!