List of Java processes

前端 未结 18 2227
长发绾君心
长发绾君心 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:26

    The following commands will return only Java ProcessIDs. These commands are very useful whenever you want to feed another process by this return values (java PIDs).

    sudo netstat -nlpt | awk '/java/ {print $7}' | tr '/java' ' '

    sudo netstat -nlpt | awk '/java/ {print $7}' | sed 's//java/ /g'

    But if you remove the latest pipe, you will notice these are java process

    sudo netstat -nlpt | awk '/java/ {print $7}'

    sudo netstat -nlpt | awk '/java/ {print $7}'

提交回复
热议问题