The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Kill a Process bennichan SUN Solaris 5 03-23-2008 10:14 PM
kill process ust UNIX for Advanced & Expert Users 1 11-27-2007 09:06 AM
kill(0,-9) don't kill the process umen High Level Programming 9 06-19-2007 03:09 AM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 09:54 AM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 01:24 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2008
Registered User
 

Join Date: Jan 2008
Posts: 13
kill process help

i wanted to kill a process by entering the process name. How am i able to kill the process that allows user to enter the process name and kills it?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-02-2008
Registered User
 

Join Date: Oct 2007
Posts: 106
Maybe You have the command killall, then You can do
Code:
killall xmms
for example. If You don't have that You may have the command pidof, to find the process id of a named process.
Reply With Quote
  #3 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Jan 2008
Posts: 13
i wanted to kill the process from entering the program name instead of the pid, how can i do so?

eg. when i do a "ps -f U username" it will print out all pid,ppid,C,stime,tty,stat,time,cmd. but i would like to kill the process by entering name of the program from the cmd column.

i use
Code:
grep programName | awk '{print $9}' | xargs kill
is not working!!!

Really hope there is someone to help me!!!
Reply With Quote
  #4 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Oct 2007
Posts: 106
Have You tried killall instead of kill?

Code:
ps -f U username|grep programName | awk '{print $9}' | xargs killall
Reply With Quote
  #5 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Jan 2008
Posts: 13
thanks Lakris!! it works!!! thanks!!!

but if i wanted to grep the input from user and kill the process how should i do it? i try but couldnt work!!!

Code:
echo "enter program name"
read input

ps -ef U username|grep $input | awk '{print $2}' | xargs killall
Reply With Quote
  #6 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Oct 2007
Posts: 106
No problem, glad to help.
Not sure what isn't working for You, but maybe this will ( if You have $USER set)

Code:
echo "enter program name"
read input

ps -ef U $USER|grep $input | awk '{print $2}' | xargs kill
If You use $2 instead of $9 You will print the process id instead of program name. So use kill instead.

/Lakris
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0