One line Linux command to kill all instances of a program or script running in the background
This one liner command that runs a "kill -9" to all background processes that matched a given search string.
If you are killing a script, use the script file name as the search string.
You might want to test out with the command below to see if the awk '{print $2}' is passing the PID column to the xargs command. If it is not passing the right data, you need to change the "$2" to select the correct column output from the "ps -ef" command.
ps -ef | grep [search string] | awk '{print $2}' | xargs kill -9
If you are killing a script, use the script file name as the search string.
You might want to test out with the command below to see if the awk '{print $2}' is passing the PID column to the xargs command. If it is not passing the right data, you need to change the "$2" to select the correct column output from the "ps -ef" command.
Comments
Post a Comment
Thank you for visiting Almost a Technocrat. Due to many spam comments, your comment will be moderated.