Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rating: Thread Rating: 113 votes, 5.00 average. Display Modes
Old 06-10-2003, 04:50 PM   #1
tmeehan
Triple-A Player
 
Join Date: Jun 2003
Posts: 65
10.1 Obtaining PID from Process Name

Does anyone know how I can derive a process ID given only it's name. The big picture is that I want to kill a process but I only know the name, not the process ID. It seems that "kill" requires the PID.

Any and all help would be appreciated.

Thanks
tmeehan is offline   Reply With Quote
Old 06-10-2003, 04:59 PM   #2
grrl_geek
Major Leaguer
 
Join Date: Feb 2003
Location: Berkeley, CA
Posts: 270
Well, you can do this in the Terminal:

ps -auwx | grep 'Name of Process'
grrl_geek is offline   Reply With Quote
Old 06-10-2003, 05:19 PM   #3
jbc
All Star
 
Join Date: Feb 2003
Location: Chico, CA
Posts: 686
Might want to read this thread for ideas:

http://forums.macosxhints.com/showth...threadid=11755
jbc is offline   Reply With Quote
Old 06-10-2003, 05:58 PM   #4
Englabenny
Triple-A Player
 
Join Date: Feb 2003
Posts: 55
Read the above linked thread, and if it's too long or not understandable, just read the last post in that thread.

It is really easy using just killall.
Englabenny is offline   Reply With Quote
Old 06-10-2003, 07:19 PM   #5
jbc
All Star
 
Join Date: Feb 2003
Location: Chico, CA
Posts: 686
Ditto what Englabenny said. Thought you might want some background though...
jbc is offline   Reply With Quote
Old 06-11-2003, 06:28 PM   #6
greggo
Prospect
 
Join Date: Jul 2002
Posts: 14
here's an AppleScript that may help...
Code:
display dialog "Enter the Name of the Application You Wish to Kill" default answer ""
set appName to (text returned of result)
do shell script "ps ax | grep -i " & appName & " | grep -v grep | cut -c 1-6"
set pNum to result
set prName to do shell script "ps cax | grep -i " & appName & " | awk '{print $5, $6}'"
display dialog "Kill Application  " & prName & " PID#" & pNum buttons {"Kill It!", "Cancel"} 
if button returned of result is "Kill It!" then
	try
		do shell script "kill -15 " & pNum
	on error
		display dialog "The Process Named \"" & appName & "\" Is Not Running"
	end try
end if
greggo is offline   Reply With Quote
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 On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:15 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.