Skip to content

Instantly share code, notes, and snippets.

@SalvadorP
Created July 9, 2013 11:14
Show Gist options
  • Save SalvadorP/5956584 to your computer and use it in GitHub Desktop.
Save SalvadorP/5956584 to your computer and use it in GitHub Desktop.
Shell script to kill all processes with a known name. An example can be creating two sleeping processes. In a terminal write sleep 1234 &. sleep 1234 &. And then ./mataprocesos.sh sleep. And it will kill al processes named with sleep. Can be copied to /bin/ and used like a normal shell command.
#!/bin/bash
if [ -z "$1" ]; then
echo ERROR. Use ./mataprocesos.sh process_name
exit
fi
kill $(ps -cef | grep $1 | awk '{print $2}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment