krystah
krystah

Reputation: 3733

xargs kill: Failure

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?

Upvotes: 0

Views: 5845

Answers (1)

chepner
chepner

Reputation: 531758

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.

Upvotes: 3

Related Questions