25

Is there any way of killing all instances of a specific program with a command-line command?

Andrea
  • 1,536
George
  • 259

7 Answers7

50

In GNU/Linux, BSD, OS X, and other Unix-likes

killall program

In Windows

taskkill /IM program.exe
Oliver Salzburg
  • 87,539
  • 63
  • 263
  • 308
4

On many system you will find the commands kill and killall.

If you know the PID of the process then you can use kill PID

The first kills only one specific process. (Or rather, it sends a signal to it, e.g. the signal to terminate). You can write a wrapper around that with ps and grep to kill all processes matching a name.

or, if installed, you could use killall

Beware though, not all killall commands do the same thing. On Solaris it kills all processes. I repeat, all. Not just those you wanted but each and every process you have the rights to kill will get killed. Make sure you check the manual page of your local system and or check if it is a link to killall5.

Hennes
  • 65,142
4

On Windows 7 (Vista?), I prefer tskill processname as you don't need to remember command line switches or write .exe at the end. eg:

tskill chrome

Will kill all chrome processes.

On windows XP I used pskill from the pstools suite, which uses a similar syntax. Both these commands can also work on remote computers, if you have admin rights.

Luke
  • 1,155
  • 1
  • 9
  • 18
2

In windows if you want to kill a process and any child processes which were started by it you should use this command Taskkill /im program.exe /t

Farhad
  • 121
1

On Windows 7 there is taskkill.

slhck
  • 228,104
Stf
  • 11
1

for Windows, you can use
taskkill /im program_name
use taskkill /im program_name /f for more problematic programs
Use ProcessExplorer if you want a GUI alternative for Taskmanager

user13267
  • 1,641
1

On Linux, the command is either pkill or killall. pkill is generally recommended, since on some systems, killall will actually kill all processes.

Brendan Long
  • 1,798
  • dis ~ # killall Usage: killall [OPTION]... [--] NAME... killall -l, --list killall -V, --version
      -e,--exact          require exact match for very long names
      -I,--ignore-case    case insensitive process name match
    ...
    
    – elcash Mar 13 '13 at 05:55
  • 1
    @Brendan Long: It is not an urban legend. On some SYS V systems killall actually kills all. That is not necessary a bad thing, but if you are not expecting it to behave differently on a different system then you might get an educational moment. – Hennes Mar 13 '13 at 11:46