linux script to kill java process

后端 未结 5 1014
情歌与酒
情歌与酒 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:36

    pkill -f for whatever reason does not work for me. Whatever that does, it seems very finicky about actually grepping through what ps aux shows me clearly is there.

    After an afternoon of swearing I went for putting the following in my start script:

    (ps aux | grep -v -e 'grep ' | grep MainApp | tr -s " " | cut -d " " -f 2 | xargs kill -9 ) || true

提交回复
热议问题