6

So I'm executing a command like:

 COMMANDNAME -PARAMETERS

But..why can't I kill it with "pkill"? I'm trying with:

 pkill -9 "COMMANDNAME -PARAMETERS"

but it doesn't kills the "COMMANDNAME -PARAMETERS" process. Why?

LanceBaynes
  • 40,135
  • 97
  • 255
  • 351

2 Answers2

21

If you need to match the full command line (command + parameters) as you reported in your example you will have to use the -f option:

pkill -9 -f "COMMANDNAME -PARAMETERS"

accordingly to the man page:

  -f     The pattern is normally only matched against the process name.
          When -f is set, the full command line is used.
ztank1013
  • 2,221
  • 2
  • 14
  • 14
0

From the man page:

pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match. pkill terminates these IDs

So the "commandname -parameters" is not matching. What you should have is just:

pkill -9 commandname

Rory Alsop
  • 2,063
  • 15
  • 30