I have process which created multiple PID's. I want to kill all those PID's. I have tried
pkill <process_name>.

But PID not getting killed as they were wait to resource releasing.

I have managed to get PID list with

ps -ef | grep <process_name> | awk '{print $2}'

which gives process ID list but how can I kill all those listed PIDs ?

Thank you.

  • 2
    what's the output of pgrep -lf <process_name> ? if it gives only the relevant processes, you can kill with pkill -f <process_name>
    – Dani_l
    Nov 29, 2015 at 11:52
  • 2
    You probably don't want to do this...
    – l0b0
    Nov 29, 2015 at 12:08
  • @l0b0 Why? because some web page says so? The pgrep -lf verification covers everything that page warns about. You can see exactly what you are about to pkill.
    – Dani_l
    Nov 29, 2015 at 12:21
  • @l0b0 how is pgrep/pkill different from ps -ef | grep <prco name>? Since it doesn't, you claim the authoritative answer is - since you didn't think to store the ppid in advance, you're out of luck. Don't trust ps names. They might lie.
    – Dani_l
    Nov 29, 2015 at 12:24
  • Hold on, I didn't say to use pgrep/pkill instead of ps | grep; they're equally bad. If you read the linked web page it explains how to do it cleanly, by making sure that the parent process is responsible for killing/relaunching processes rather than relying on a PID file or pgrep/pkill. Of course, I assume OP is trying to automate this because of the form of the question. If that's not the case there's no point in being picky.
    – l0b0
    Nov 29, 2015 at 12:28

2 Answers 2


You could pipe the output to xargs e.g.

ps -ef | grep <process_name> | awk '{print $2}' | xargs /bin/kill

But why doesn't your pkill command work?



pgrep process_name | xargs kill


ps -e | awk '/[p]roces_name/ {system("kill "$1}
  • 2
    Or pkill -f ...
    – Dani_l
    Nov 29, 2015 at 12:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .