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
ypbind - multiple instances starting blowtorch SUN Solaris 0 10-01-2007 03:51 AM
detecting multiple instances ragha81 Shell Programming and Scripting 3 04-06-2007 07:09 AM
Creating instances of a program tushar_johri Shell Programming and Scripting 2 05-25-2005 07:36 AM
Multiple file instances gozer13 UNIX for Dummies Questions & Answers 1 12-29-2004 03:08 PM
multiple instances of syslogd - is it possible? Gary Dunn UNIX for Advanced & Expert Users 9 07-20-2004 06:10 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-15-2007
Registered User
 

Join Date: Aug 2005
Location: in my heart. ..kidding. Calcutta, India.
Posts: 13
kill multiple instances of the same program

Hi,

I know that the answer to this is very simple, since I saw somebody do it some time back..but I forgot how.

The problem is, I have multiple instances of the same program running simultaneously and I want to kill them all in a single command.

I know that it can be done using awk '{print $2}' in combination with ps and kill but I am not able to formulate the exact command.

The process in question (to be killed) is xterm.

will deeply appreciated all help.

ipzig
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-15-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
if you have pkill it is a doddle....

Code:
pkill xterm

Last edited by porter; 12-16-2007 at 12:33 AM.
Reply With Quote
  #3 (permalink)  
Old 12-16-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,470
Quote:
Originally Posted by porter View Post
if you have pkill it is a doddle....

[code]pkill xterm[/CODE[
Will pkill kill only the instance that a user has permission to kill ?

user A can run the instance proc p1
and user B can also run the same instance proc p1

will pkill identify only the instances from user A and kill only those instances of proc p1

( may be something like ps -fu $user )
Reply With Quote
  #4 (permalink)  
Old 12-16-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by matrixmadhan View Post
Will pkill kill only the instance that a user has permission to kill ?
It can't kill the ones you don't.

Last edited by porter; 12-16-2007 at 11:14 AM.
Reply With Quote
  #5 (permalink)  
Old 12-16-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,470
Quote:
Originally Posted by porter View Post
It can't kill the once you don't.
Well, that is true.
Am interested to know whether it would skip it as such or will throw an error stating unable to kill the other instance.

I will check that !
Reply With Quote
  #6 (permalink)  
Old 12-16-2007
Registered User
 

Join Date: Aug 2005
Location: in my heart. ..kidding. Calcutta, India.
Posts: 13
I don't have pkill.

Yet, I know the answers a doddle if you can combine kill, ps -fu, and awk '{print $2}' (with ps).

Only, am not able to do it myself, and waiting for a shell expert to do it for me..

Regards
ipzig
Reply With Quote
  #7 (permalink)  
Old 12-16-2007
in2nix4life's Avatar
Registered User
 

Join Date: Oct 2007
Location: East Coast
Posts: 43
As long as you know the name of the process take a look at the 'killall' command.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:25 AM.


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