adb: Find PID from the adb shell

前端 未结 4 628
自闭症患者
自闭症患者 2020-12-20 20:22

I am trying to get the PID of the process INSIDE adb shell. So, I am doing adb shell which gets me to the android shell. Now, if I were to get the PID using a regular shell

相关标签:
4条回答
  • 2020-12-20 20:42

    I tried this one and it seems to work:

    1.adb shell -> ps -A | grep "android.process.acore"

    0 讨论(0)
  • 2020-12-20 21:03

    I tried this one and it seems to work:

    adb shell "set "ps | grep android.process.media"; kill -9 $2"
    
    0 讨论(0)
  • 2020-12-20 21:04

    Android versions starting with 6.0 already include pidof utility:

    usage: pidof [-s] [-o omitpid[,omitpid...]] [NAME]...
    
    Print the PIDs of all processes with the given names.
    
    -s      single shot, only return one pid.
    -o      omit PID(s)
    
    0 讨论(0)
  • 2020-12-20 21:09

    Not sure if you can get the PID directly however you can try the following

    set `ps |grep android.process.acore`
    echo $2
    

    This has the affect of setting the output of the ps command into variables $1, $2, $3 etc. The PID value is in $2

    0 讨论(0)
提交回复
热议问题