LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 09-07-2004, 11:16 PM   #1
jwprz70
LQ Newbie
 
Registered: Sep 2004
Location: Washington
Posts: 3

Rep: Reputation: 0
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.
 
Old 09-07-2004, 11:27 PM   #2
fenderman11111
Member
 
Registered: Jun 2004
Location: Denton
Distribution: debian, freebsd
Posts: 121

Rep: Reputation: 15
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'
 
Old 09-07-2004, 11:53 PM   #3
tim1235
Member
 
Registered: Aug 2004
Location: Melbourne, Australia
Distribution: fc5/Gentoo
Posts: 57

Rep: Reputation: 15
You can also force a kill with the -9 option

i.e kill -9 2345
 
Old 09-08-2004, 01:43 AM   #4
chii-chan
Member
 
Registered: Sep 2003
Location: chikyuu (E103N6)
Distribution: Redhat 8.0 (2.4.25-custom), Fedora Core 1 (2.4.30-custom)
Posts: 357

Rep: Reputation: 30
Use "killall process_name" to kill by name.
 
Old 09-08-2004, 07:46 PM   #5
jwprz70
LQ Newbie
 
Registered: Sep 2004
Location: Washington
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 09-08-2004, 09:52 PM   #6
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
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.
 
Old 09-08-2004, 09:53 PM   #7
rjtucke
Member
 
Registered: Sep 2004
Distribution: Debian testing
Posts: 49

Rep: Reputation: 16
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?
 
Old 09-09-2004, 01:52 AM   #8
pippet
Member
 
Registered: May 2004
Posts: 67

Rep: Reputation: 15
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
 
Old 09-09-2004, 06:51 AM   #9
phoenix7
Member
 
Registered: Aug 2004
Distribution: Mandrake 10.2(Mandriva), SuSE 9.3, Slackware 9.1, Xandros 3.1, Knoppix 3.9, FreeBSD 5.3, RedHat9
Posts: 122

Rep: Reputation: 15
Hi
you can get programs uid and pid by running
Code:
ps
then you can use
Code:
killall UID
or
Code:
kill PID
if you use '-9' option of kill & killall you can sure about terminating that program

Cheers,
Mohammad
 
Old 05-08-2010, 04:50 PM   #10
jkastelic
LQ Newbie
 
Registered: May 2010
Posts: 1

Rep: Reputation: 0
Hello!

A more elegant options is to use

Code:
kill -9 $(jobs -p)
Cheers,
Jakob
 
Old 05-12-2010, 02:29 AM   #11
ksdeepu
LQ Newbie
 
Registered: May 2007
Posts: 1

Rep: Reputation: 0
kill -9 %jobid will do
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
running jobs on the background feetyouwell Linux - Software 3 08-02-2005 11:36 AM
Background jobs paddyjoy Linux - Newbie 2 07-19-2005 02:46 AM
mandrake 9.2 kill jobs krome Mandriva 3 06-04-2005 03:56 AM
Commands (jobs and kill) xviddivxoggmp3 Linux - General 2 08-01-2004 10:42 PM
background jobs seize630 Linux - General 6 10-14-2003 04:16 PM


All times are GMT -5. The time now is 08:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration