Solved

kill certain process

Posted on 2002-07-22
3
221 Views
Last Modified: 2012-05-04
we can use the following to kill process by name

$cat kill1
kill `ps|grep $1|awk '{print $1}'`

then we can call it by kill1 sleep

But there is a problem, it will kill all process named sleep. How can I change it so that it only kills a certain process, such as the third one or the first one?
0
Comment
Question by:ww111697
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
ID: 7169882
awk 'NR==1{print $1}'
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7170383
kill `ps|awk '($4 ~ /'$1'$/){print}'`
# keep in mind that you might get more than one process
0
 

Author Comment

by:ww111697
ID: 7179223
very good answer
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now