Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I need to kill multiple java processes running with one command, any tips please. ps -ef|grep java|awk '{print $2}' gives all the process numbers , i think some 'cut ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Posts
    16

    Kill multiple java processes at once


    Hi,

    I need to kill multiple java processes running with one command, any tips please.

    ps -ef|grep java|awk '{print $2}' gives all the process numbers , i think some 'cut ' command is there but not sure.

  2. #2
    Linux Newbie
    Join Date
    Sep 2003
    Location
    St.Charles, Missouri, USA
    Posts
    201
    Code:
    su -c 'killall -9 java'
    Powered by Gentoo
    never ever ever use the hardened option in make.conf!

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Posts
    16
    What if i have 50 pids (running for a particular user) and i need to kill all at once.How do i address that , as i said earlier , i could get the pid column list by awk and grep.

    How do i kill all pid's at once?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Apr 2005
    Location
    Charlottesville, VA
    Posts
    175
    Code:
    kill -9 `ps -ef|grep java|grep -v grep|awk '{print $2}'`
    should do it for you.
    ---sxeraverx---
    Linux without a C Compiler is like eating Spaghetti with your mouth sewn shut. It just doesn't make sense.

  6. #5
    Just Joined!
    Join Date
    Apr 2005
    Posts
    44
    kill -9 `ps -ef|grep java|grep -v grep|awk '{print $2}'`
    yea, thatshould defintely do it for you, i use almost the same sequence of commands to kill mutliple instances for web browsers as a demonstration at my old skool...if that dont work, then either you are not root, or it cant find all of the java processes (which it shouldnt do). the command in the quote that i put up from sxeraverx should do it, unless using the su command along with it.

  7. #6
    Just Joined!
    Join Date
    Oct 2008
    Posts
    1

    Another way to kill multiple java process

    ps -ef | grep java | grep -v grep | awk '{print $2}' | xargs kill -9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •