List of Java processes

前端 未结 18 2205
长发绾君心
长发绾君心 2020-12-22 16:44

How can I list all Java processes in bash? I need an command line. I know there is command ps but I don\'t know what parameters I need to use.

相关标签:
18条回答
  • 2020-12-22 17:04
    pgrep -l java
    ps -ef | grep java
    
    0 讨论(0)
  • 2020-12-22 17:04
     ps -eaf | grep [j]ava
    

    It's better since it will only show you the active processes not including this command that also got java string the [] does the trick

    0 讨论(0)
  • 2020-12-22 17:05

    try:

    ps aux | grep java
    

    and see how you get on

    0 讨论(0)
  • 2020-12-22 17:07
    ps axuwww | grep java | grep -v grep
    

    The above will

    • show you all processes with long lines (arg: www)
    • filter (grep) only lines what contain the word java, and
    • filter out the line "grep java" :)

    (btw, this example is not the effective one, but simple to remember) ;)

    you can pipe the above to another commands, for example:

    ps axuwww | grep java | grep -v grep | sed '.....'  | while read something
    do
        something_another $something
    done
    

    etc...

    0 讨论(0)
  • 2020-12-22 17:08

    You can use single command pgrep as well (doesn't require you to use pipes and multiple commands):

    pgrep -fl java
    
    0 讨论(0)
  • 2020-12-22 17:10
    jps -lV
    

    is most useful. Prints just pid and qualified main class name:

    2472 com.intellij.idea.Main
    11111 sun.tools.jps.Jps
    9030 play.server.Server
    2752 org.jetbrains.idea.maven.server.RemoteMavenServer
    
    0 讨论(0)
提交回复
热议问题