Killing linux process by piping the id

前端 未结 4 1804
一个人的身影
一个人的身影 2021-01-27 13:31

I want to kill a process and I get its id with:

pgrep -f \"python myscript.py\"

I would like to call

kill -s SIGINT 

4条回答
  •  情歌与酒
    2021-01-27 14:24

    It's generally most convenient to use xargs to pass data from a pipe as arguments to a command that doesn't read data from stdin themselves:

    pgrep -f "python myscript.py" | xargs kill -s SIGINT
    

提交回复
热议问题