How can I kill all stopped jobs?

Solution 1:

To quickly kill all the stopped jobs under the bash, enter:

kill -9 `jobs -ps`

jobs -ps lists the process IDs (-p) of the stopped (-s) jobs.
kill -9 `jobs -ps` sends SIGKILL signals to all of them.

Solution 2:

Try typing this:

kill -9 $(jobs -p)

Solution 3:

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:

kill $(jobs -l | grep Stopped | cut -d' ' -f3)

Solution 4:

The easiest way is actually to simply immediately retry the exit; bash will take that to mean "kill all stopped jobs and exit".


Solution 5:

for x in `jobs -p` ; do kill -9 $x ; done

Tags:

Linux

Shell