Search code examples
androidwindowsshelladbps

Kill pid by found name in adb shell


I am trying kill the process by pid but without success yet. To get pid I use command in adb shell:

echo $(ps |grep myword) | cut -d' ' -f2

To kill pid I use command:

kill <PID>

But I cannot join that two commands.. What I've tried was:

kill $($(ps |grep debug) | cut -d' ' -f2)

but it is somehow wrong. Could I ask you for a help?

tl;dr

The problem is about joining two commands in adb shell, android console -to kill process found by name.

echo $(ps |grep myword) | cut -d' ' -f2
kill <PID>

I forgot to say: I am working on Windows7, so grep might not working in console. Really sorry for this.

I also tried this command:

adb shell "su -c 'echo $(ps | grep process_name) | cut -d' ' -f2 | xargs kill'"

This example is working well, however last part xargs fails:

adb shell ^" "su -c 'echo $(ps | grep ror)'|cut -d' ' -f2"

Solution

  • The solution for command adb shell in windows7 was:

    adb shell ^" "su -c 'ps | echo $(grep process_name) | cut -d " " -f2 |xargs kill '"