Solved

kill certain process

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

762 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