Using “kill” unix command with pipe

By neokrates, written on May 4, 2010

bash   snippet

  • Join date: 11-30-99
  • Posts: 224
View Counter:
  • 107 views
Rate it
Ad
Poll
  • What build management tool does your project or firm use?

    View Results

    Loading ... Loading ...
Feeds:
  • bodytext bodytext bodytext

Su can execute commands under other user without interaction.

Example:

Normal pipe doesn’t work with kill. Here is what does work.

I have started many java processes and now want to get rid of them:

kill -9 `ps -ef | grep "java" | awk '{print $2}'`

 

💡 Remark: ps -ef | grep "my_token" is a common way to find some process, so if I started tomcat with ./wrapper start I would list it like:

ps -ef | grep "tomcat"
or
ps -ef | grep "wrapper"
Be Sociable, Share!
 
Does that help to solve your problem?
VN:F [1.8.5_1061]
Rating: 0 (from 2 votes)
1 votes 'YES'  1 votes 'NO'
TAGS
No tags for this post.
RELATED
Pages
Posts
SOCIAL
Be Sociable, Share!

Leave a Reply