Solved

kill certain process

Posted on 2002-07-22
3
220 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate FIPS 140-2 Public Key on Unix 5 66
How to Change Interface on Cisco IOU 11 83
can't umount nfs share after server goes offline... 4 74
Image not there 4 44
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 …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

910 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

21 Experts available now in Live!

Get 1:1 Help Now