-   Linux - Newbie (
-   -   Kill all Background Jobs (

jwprz70 09-07-2004 10:16 PM

Kill all Background Jobs
How do you kill all background jobs? I have tried Kill 0 and Kill -0, and they do not seem to work.

fenderman11111 09-07-2004 10:27 PM

you can't kill a job #, only a pid

so, do 'ps aux' and then find your process... kill the pid of it. it's the big #, more than 3 digits probably...

so like 'kill 2376'

tim1235 09-07-2004 10:53 PM

You can also force a kill with the -9 option

i.e kill -9 2345

chii-chan 09-08-2004 12:43 AM

Use "killall process_name" to kill by name.

jwprz70 09-08-2004 06:46 PM

What if you have multiple background jobs running? The point is I need to be able to kill all background jobs, not individual ones in which I know the PID.

CroMagnon 09-08-2004 08:52 PM

hi jwprz - you can use "jobs -p" to get the process ids of every background job.

then (if you're *sure* you want to kill every job), you can do this:

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

The -9 might or might not be necessary depending on your situation.

rjtucke 09-08-2004 08:53 PM

This is as a regular user, right? IE, not as root?
If you give me more info on what exactly you are doing, I will help you code up a perl script to do it. Like, when you say background, does that mean all processes listed under ps -x?

pippet 09-09-2004 12:52 AM

do u want to kill all background jobs of a particular type? for example, all instances of mozilla?
if that is the case use
$killall programmename

phoenix7 09-09-2004 05:51 AM

you can get programs uid and pid by running

then you can use

killall UID

kill PID
if you use '-9' option of kill & killall you can sure about terminating that program


jkastelic 05-08-2010 03:50 PM


A more elegant options is to use


kill -9 $(jobs -p)

ksdeepu 05-12-2010 01:29 AM

kill -9 %jobid will do

All times are GMT -5. The time now is 07:26 AM.