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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top