shell - How to Kill Processes in Bash -


i used following bash code:

for pid in `top -n 1 | awk '{if($8 == "r") print $1;}'`   kill $pid done 

it says:

./kill.sh: line 3: kill: 29162: arguments must process or job ids ./kill.sh: line 3: kill: 29165: arguments must process or job ids ./kill.sh: line 3: kill: 29166: arguments must process or job ids ./kill.sh: line 3: kill: 29169: arguments must process or job ids 

what causes error , how kill processes in bash?

probably awk command not returning reliable data, in case theres easier way:

kill `pidof r` 

or:

killall r 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -