Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I kill a process running with in multiple sessions using a bash or powershell script?

share|improve this question
your question and your body state different things, please elaborate your question – freethinker May 19 '11 at 9:51

On Windows-machines with powershell installed, you can just do this:

get-process PROCESS_NAME | stop-process

share|improve this answer

Bash alternative

pgrep killus | while read p; do kill -9 $p; done

kills all processes named killus

share|improve this answer

Are you looking to automate this, or just to have a tool available where you can manually kill multiple instances of a process by name, regardless of what user session any instance is running in? I'm assuming the latter, and the following should accomplish that.

On Windows, you can't beat Sysinternals' "pskill" utility. Get the SysInternals suite, unpack, and at a command prompt simply use pskill theprocessname to deep-six all instances of the corresponding executable.

The following bash script would provide similar functionality on Linux; I'll leave it to the user to figure out how to loop it until no more instances exist:

if [ $1 -eq ""]; then
echo "Usage : ./ <process name>"
get_proc=`ps -e -o pid,command | grep $1`
echo $get_proc > get_it
get_pid=`gawk -F" " '{ print $1 }' get_it`
kill -9 $get_pid

(Script lifted directly from, but pasting it here for posterity because I hate finding dead links in answers on StackExchange sites.)

Hope this helps!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .