Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

kill multiple instances of the same program

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-16-2007   -   Original Discussion by ipzig
ipzig ipzig is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 19 September 2012, 12:59 AM EDT
Location: in my heart. ..kidding. Calcutta, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old Unix and Linux 12-16-2007   -   Original Discussion by ipzig
porter porter is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 8 January 2008, 6:50 PM EST
Posts: 2,965
Thanks: 0
Thanked 5 Times in 5 Posts
if you have pkill it is a doddle....


Code:
pkill xterm


Last edited by porter; 12-16-2007 at 04:33 AM..
Sponsored Links
    #3  
Old Unix and Linux 12-16-2007   -   Original Discussion by ipzig
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 10 January 2017, 8:10 AM EST
Location: classification algos
Posts: 3,215
Thanks: 19
Thanked 31 Times in 28 Posts
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 )
    #4  
Old Unix and Linux 12-16-2007   -   Original Discussion by ipzig
porter porter is offline Forum Advisor  
Registered User
 
Join Date: Jan 2007
Last Activity: 8 January 2008, 6:50 PM EST
Posts: 2,965
Thanks: 0
Thanked 5 Times in 5 Posts
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. Linux

Last edited by porter; 12-16-2007 at 03:14 PM..
Sponsored Links
    #5  
Old Unix and Linux 12-16-2007   -   Original Discussion by ipzig
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
 
Join Date: Mar 2005
Last Activity: 10 January 2017, 8:10 AM EST
Location: classification algos
Posts: 3,215
Thanks: 19
Thanked 31 Times in 28 Posts
Quote:
Originally Posted by porter View Post
It can't kill the once you don't. Linux
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 ! Linux
Sponsored Links
    #6  
Old Unix and Linux 12-16-2007   -   Original Discussion by ipzig
ipzig ipzig is offline
Registered User
 
Join Date: Aug 2005
Last Activity: 19 September 2012, 12:59 AM EDT
Location: in my heart. ..kidding. Calcutta, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
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.. Linux

Regards
ipzig
Sponsored Links
    #7  
Old Unix and Linux 12-16-2007   -   Original Discussion by ipzig
in2nix4life's Unix or Linux Image
in2nix4life in2nix4life is offline
Registered User
 
Join Date: Oct 2007
Last Activity: 9 October 2016, 12:41 PM EDT
Location: East Coast
Posts: 621
Thanks: 1
Thanked 177 Times in 163 Posts
As long as you know the name of the process take a look at the 'killall' command.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Control multiple program instances - open multiple files problem hakermania Programming 3 02-06-2011 01:06 PM
Multiple instances of a job. Gangegowda Shell Programming and Scripting 1 10-16-2008 05:22 AM
Creating instances of a program tushar_johri Shell Programming and Scripting 2 05-25-2005 11:36 AM
Multiple file instances gozer13 UNIX for Dummies Questions & Answers 1 12-29-2004 07:08 PM
multiple instances of syslogd - is it possible? Gary Dunn UNIX for Advanced & Expert Users 9 07-20-2004 10:10 AM



All times are GMT -4. The time now is 07:51 PM.