0

Consider the following command:

ps ax | ack -i "[p]rocessname" | awk '{print $1}'

This lists the PID's of the processes matching processname.

When I attempt to kill each of these processes like this,

ps ax | ack -i "[p]rocessname" | awk '{print $1}' | xargs kill

I get the following errors:

kill: 90632: Operation not permitted
kill: 90642: Operation not permitted
kill: 90724: Operation not permitted
kill: 90732: Operation not permitted

I'm thinking xargs might be treating the pids as Strings instead of integers or something in that manner. Or perhaps I should use cut instead of awk here (I'm new to awk). Any advice?

krystah
  • 3,587
  • 2
  • 25
  • 43

1 Answers1

3

The command is fine. You simply don't have permission to kill the processes returned by awk. In Unix, only the root user can kill processes owned by another user.

chepner
  • 497,756
  • 71
  • 530
  • 681