Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Is there a reason why you wouldn't use pkill -f to kill the matching processes, and why you rather introduce a race condition by first calling pgrep -f and then kill? Commented Sep 24, 2020 at 18:06
  • pkill just sends sigterm and in my case, it did not kill any of my processes. pkill -SIGKILL also did not work. pgrep -f returns the pid of matching processes and as I stated, this worked perfectly while the others did not. Commented Sep 24, 2020 at 20:56
  • You will notice that pkill also has the -f option which makes it match the pattern against the full command line, just like pgrep -f does. The difference being that pkill also sends a signal to the matching processes. With pkill -f -SIGKILL pattern you therefore send the KILL signal to any process whose command line matches pattern. Commented Sep 24, 2020 at 22:45
  • 1
    I tried "pkill -f -SIGKILL pattern" but didn't kill my processes but "kill -9 $(pgrep -f somepattern)" killed all of them. Commented Oct 30, 2020 at 22:03
  • pkill -f -SIGKILL pattern fails miserably. it even reports Killed when pattern is a running process or not even a running process. what?!?! the other methods, like this answer, works. something is not right with pkill Commented Jul 9, 2021 at 16:25