linux script to kill java process

后端 未结 5 1051
情歌与酒
情歌与酒 2021-01-30 01:04

I want linux script to kill java program running on console.

Following is the process running as jar.

[rapp@s1-dlap0 ~]$ ps -ef |grep java
rapp    9473           


        
5条回答
  •  情深已故
    2021-01-30 01:40

    Use jps to list running java processes. The command returns the process id along with the main class. You can use kill command to kill the process with the returned id or use following one liner script.

    kill $(jps | grep  | awk '{print $1}')
    

    MainClass is a class in your running java program which contains the main method.

提交回复
热议问题