LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-16-2007, 08:46 AM   #1
spes_hominis
Member
 
Registered: Jun 2004
Location: N. Ireland
Distribution: Zenwalk 6.2
Posts: 30

Rep: Reputation: 15
Combining two commands into one


Due to an unresolved bug in Flash (fix it,Adobe!),Firefox keeps locking up,hard. Xkill gets rid of the window,but leaves the process running;the only way to shut it down cleanly is by grepping for the process number:
Code:
ps -A | grep firefox-bin
5635 ?     00:13:01 firefox-bin
Then doing
Code:
kill number
How do I pass the process number into kill to avoid typing it out each time?
 
Old 05-16-2007, 08:50 AM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
You could just do:

Code:
killall firefox-bin
 
Old 05-16-2007, 08:52 AM   #3
spes_hominis
Member
 
Registered: Jun 2004
Location: N. Ireland
Distribution: Zenwalk 6.2
Posts: 30

Original Poster
Rep: Reputation: 15
That worked,thanks! Why doesn't kill accept process names?
 
Old 05-16-2007, 09:05 AM   #4
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
Quote:
Originally Posted by spes_hominis
That worked,thanks! Why doesn't kill accept process names?
Kill is designed to kill one specific process. So, if multiple processes with the same name exist, which one to kill?

The killall command avoids such confusion by just killing all processes with that name ;-)

Nice sig, by the way. You should finish it with "it != difficult" for maximum effect ;-)

Groetjes,

Kees-Jan
 
Old 05-16-2007, 09:18 AM   #5
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
You might also like pkill and pgrep, both of which accept process names, but work much like their p-less counterparts. For example, to kill all instances of firefox, you could grep out all their process numbers, and then kill them all with kill:
Code:
ps -ef | grep firefox
kill -9 <process numbers from above command>
Or, you could just do
Code:
pkill -9 firefox
which would have the same effect.

Last edited by pwc101; 05-16-2007 at 09:20 AM.
 
Old 05-16-2007, 10:51 AM   #6
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
I know your problem was solved with the killall command, but I'd like to show just another way:
Quote:
Originally Posted by spes_hominis
How do I pass the process number into kill to avoid typing it out each time?
Code:
kill $(ps -A | grep firefox-bin | awk '{print $1}')
in this way, the PID value from ps is placed as a argument to kill, the exact thing you asked for.
 
  


Reply



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
Combining Shares DriverJC Linux - Networking 1 02-11-2007 01:54 AM
Combining 2 NIC Bobymc Linux - Networking 12 06-24-2006 10:43 AM
combining old 486's??? Peppercorn Linux - Software 5 01-22-2004 06:04 PM
Need help combining MPG's snatale1 Linux - Newbie 1 11-28-2003 11:46 PM
Combining mpegs? BajaNick Linux - Software 4 09-25-2003 11:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:20 PM.

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
Open Source Consulting | Domain Registration