Android shell tricks: ps
If you ever played around with the adb shell
you may have found that the ps
utility, which lists process lists, is not as verbose as you would expect it to be. And, to make things worse, there’s no inline help or man
entries. Here’s the ps
utility usage line: ps -t -x -P -p -c [pid|name]
.
-t
show threads, comes up with threads in the list-x
shows time, user time and system time in seconds-P
show scheduling policy, eitherbg
orfg
are common, but alsoun
ander
for failures to get policy-p
show priorities, niceness level-c
show CPU (may not be available prior to Android 4.x) involved[pid]
filter by PID if numeric, or…[name]
…filter by process name
Android’s core toolbox (shell utilities) are more primitive than the ones you may be used to. Notice how each argument needs to be separated and you can’t just -txPc
it all, the command line argument parser is non-complex.
It’s a pity how command line arguments are not shown. If you need something that’s not available by the stock ps
shell utility, try manually combing through the /proc
directory. For the command line one would do cat /proc/<pid>/cmdline
.
Hi,
It’s so cool doc for newly of android.
Now, I meet a trouble when I use command for one android device. that’s run “adb shell ps”, it output some parts and blocked.
Could you help me resolve it? Thanks so much.
BTW, the parameter name does not work for me. (Android ver: 4.1.2)
Hi Jazz, not sure what you mean but feel free to get in touch with me via the contact page.