How can I kill a process by name instead of PID?

后端 未结 18 2822
孤独总比滥情好
孤独总比滥情好 2020-11-28 17:10

Sometimes when I try to start Firefox it says \"a Firefox process is already running\". So I have to do this:

jeremy@jeremy-desktop:~$ ps aux | grep firefox
         


        
18条回答
  •  臣服心动
    2020-11-28 17:59

    Strange, but I haven't seen the solution like this:

    kill -9 `pidof firefox`
    

    it can also kill multiple processes (multiple pids) like:

    kill -9 `pgrep firefox`
    

    I prefer pidof since it has single line output:

    > pgrep firefox
    6316
    6565
    > pidof firefox
    6565 6316
    

提交回复
热议问题