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.
Question
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?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow