Questions tagged [kill]

kill - Send a specified signal to a process or process group.

Questions about the kill shell utility and the kill(2) function on which it is based, which send a signal to a process or a process group.

671 questions
611
votes
15 answers

What if 'kill -9' does not work?

I have a process I can't kill with kill -9 . What's the problem in such a case, especially since I am the owner of that process. I thought nothing could evade that kill option.
tshepang
  • 64,472
  • 86
  • 223
  • 290
434
votes
9 answers

When should I not kill -9 a process?

I am always very hesitant to run kill -9, but I see other admins do it almost routinely. I figure there is probably a sensible middle ground, so: When and why should kill -9 be used? When and why not? What should be tried before doing it? What kind…
Mikel
  • 56,387
  • 13
  • 130
  • 149
331
votes
12 answers

How to terminate a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to terminate its process, then re-run the command. How can I terminate it? I haven't closed its shell window. But as you know it doesn't stop using…
144
votes
7 answers

How to kill a runaway cat?

Many times I accidentally run the cat command on files that have contents up to few thousand lines. I try to kill the cat command with Ctrl+ C or Ctrl+Z, but both only take effect after the total output of cat is displayed in the terminal, so I have…
JigarGandhi
  • 4,820
  • 10
  • 27
  • 38
134
votes
8 answers

How do I kill all screens?

I accidentally created over 1000 screens. How do I kill them all with one command? (Or a few)
BrainStone
  • 3,534
  • 12
  • 32
  • 53
116
votes
3 answers

What does `kill -0` do?

I recently came across this in a shell script. if ! kill -0 $(cat /path/to/file.pid); then ... do something ... fi What does kill -0 ... do?
slm
  • 363,520
  • 117
  • 767
  • 871
114
votes
5 answers

Kill all descendant processes

I'm writing an application. It has the ability to spawn various external processes. When the application closes, I want any processes it has spawned to be killed. Sounds easy enough, right? Look up my PID, and recursively walk the process tree,…
MathematicalOrchid
  • 5,664
  • 7
  • 35
  • 62
110
votes
12 answers

Kill many instances of a running process with one command

Suppose I have a thousand or more instances of any process (for example, vi) running. How do I kill them all in one single shot/one line command/one command?
The Dark Knight
  • 2,124
  • 4
  • 19
  • 20
94
votes
3 answers

How does Linux "kill" a process?

It often baffles me that, although I have been working professionally with computers for several decades and Linux for a decade, I actually treat most of the OS' functionality as a black box, not unlike magic. Today I thought about the kill command,…
seratoninant
  • 813
  • 1
  • 7
  • 6
88
votes
5 answers

What's the difference between pkill and killall?

I know that pkill has more filtering rules than killall. My question is, what is the difference between: pkill [signal] name and killall [signal] name I've read that killall is more effective and kill all processes and subprocesses (and…
mavillan
  • 3,067
  • 4
  • 22
  • 27
82
votes
4 answers

Default exit code when process is terminated?

When a process is killed with a handle-able signal like SIGINT or SIGTERM but it does not handle the signal, what will be the exit code of the process? What about for unhandle-able signals like SIGKILL? From what I can tell, killing a process with…
Cory Klein
  • 18,391
  • 26
  • 81
  • 93
79
votes
2 answers

Will Linux start killing my processes without asking me if memory gets short?

I was running a shell script with commands to run several memory-intensive programs (2-5 GB) back-to-back. When I went back to check on the progress of my script I was surprised to discover that some of my processes were Killed, as my terminal…
NeutronStar
  • 1,611
  • 4
  • 17
  • 19
77
votes
4 answers

Linux: Kill process based on arguments

How can I kill a process based on its command line arguments? killall, pgrep, and pkill seem to only work based on the process name. I need this to be able to differentiate between a number of applications running inside Java virtual machines,…
Mark Howard
  • 873
  • 1
  • 6
  • 4
67
votes
3 answers

What is the difference between kill , pkill and killall?

I am familiar with kill command , and most of the time we just use kill -9 to kill a process forcefully, there are many other signals that can be used with kill. But I wonder what are the use cases of pkill and killall, if there is already a kill…
Ijaz Ahmad
  • 7,146
  • 5
  • 32
  • 45
56
votes
4 answers

How do I exit or cancel a bad bash command?

I expect to get some flak for this, but I can't find the answer anywhere. It seems like it should be so obvious. Sometimes, when I type a bad command in a bash terminal, the cursor just jumps down to the next line without any error or anything. I…
Big McLargeHuge
  • 3,044
  • 11
  • 35
  • 49
1
2 3
44 45