The accepted answer would kill all jobs (which is sufficient in this case) and not merely the stopped ones. Should you want to kill only the Stopped ones, run:
Normally if you got that message, you need to logout twice. E.g. first Ctrl+D gives you the warning message to inform you about stopped jobs, pressing for the second time will log you out killing the jobs. This the same applies to logout and exit commands.
To kill them manually, try: kill $(jobs -p).
If you don't want to kill jobs from your current shell, you can remove them from the table of active jobs without killing by using disown command. E.g.
Stopped jobs also can be determined by the state of the process (T character) which means the process was stopped by signal such as SIGSTOP, SIGTSTP or other (like SIGTTIN, or SIGTTOU).
In case when jobs a shell builtin command is not available, stopped processes can be listed by the following command:
Just in case this helps someone else -- most people are here because they have some stopped processes that they started, backgrounded via the shell maybe. I needed to find processes, as root, stopped by other users, for which variants on the jobs command won't do.
A bit of digging around with man ps got me to this:
ps -a -o pid,user,cmd,state | grep 'T$'
Explanation: the -a flag says show all processes, then -o controls output, what info will be shown about each process. I'm choosing pid, user, cmd (the command line), and state, which is the process state.
From man ps:
PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the
state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped, either by a job control signal or because it is being traced
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent
so finally I pipe it to grep T$ which says, show me all the processes that have T in the last column.
And then I have a nice list of all the processes from different users that are in the stopped state.
$ ps -a -o pid,user,cmd,state | grep 'T$'
865 joson74+ python T
885 joson74+ sh -c less T
886 joson74+ less T
1014 minames+ python3.4 -i /home/minames T
5352 MooKo nano stdio.h T
7851 harry tmux attach T
12083 harry tmux attach T
13495 gorylla+ python3.4 -i /home/gorylla1 T
18009 conr1d vim T
19664 enythin+ python T
24906 wardlist python T
To quickly kill all the stopped jobs under the bash, enter:
jobs -ps
lists the process IDs (-p
) of the stopped (-s
) jobs.kill -9 `jobs -ps`
sends SIGKILL signals to all of them.Try typing this:
The accepted answer would kill all jobs (which is sufficient in this case) and not merely the stopped ones. Should you want to kill only the Stopped ones, run:
The easiest way is actually to simply immediately retry the exit;
bash
will take that to mean "kill all stopped jobs and exit".Normally if you got that message, you need to logout twice. E.g. first Ctrl+D gives you the warning message to inform you about stopped jobs, pressing for the second time will log you out killing the jobs. This the same applies to
logout
andexit
commands.To kill them manually, try:
kill $(jobs -p)
.If you don't want to kill jobs from your current shell, you can remove them from the table of active jobs without killing by using
disown
command. E.g.Stopped jobs also can be determined by the state of the process (
T
character) which means the process was stopped by signal such asSIGSTOP
,SIGTSTP
or other (likeSIGTTIN
, orSIGTTOU
).In case when
jobs
a shell builtin command is not available, stopped processes can be listed by the following command:To kill them all, you can basically type:
Here is a simple test:
Just in case this helps someone else -- most people are here because they have some stopped processes that they started, backgrounded via the shell maybe. I needed to find processes, as root, stopped by other users, for which variants on the
jobs
command won't do.A bit of digging around with
man ps
got me to this:Explanation: the
-a
flag says show all processes, then-o
controls output, what info will be shown about each process. I'm choosingpid
,user
,cmd
(the command line), andstate
, which is the process state.From
man ps
:so finally I pipe it to
grep T$
which says, show me all the processes that have T in the last column.And then I have a nice list of all the processes from different users that are in the stopped state.
If you want to remove some stopped jobs but not all, try this:
First, list jobs, you will get something like this:
send kill to a stopped job, it will do nothing but queue than bring it in in foreground, it will terminate