装载网友此篇文章,也作为自己的学习笔记,谢谢。
常规方法
1、首先,用ps查看进程,命令为:adb shell ps
...... root 32026 2 0 0 000b6a94 00000000 S kworker/2:0 root 32027 2 0 0 000b6a94 00000000 S kworker/0:0 root 32046 2 0 0 000b6a94 00000000 S kworker/4:2 root 32214 2 0 0 000b6a94 00000000 S kworker/7:0 u0_a97 32219 378 1597708 83636 ffffffff f6fc2ed0 S com.sdu.didi.psnger root 32319 2 0 0 000b6a94 00000000 S kworker/6:0 root 32361 396 4188 1200 00000000 917ba400 R ps ......
此时如果想杀死滴滴进程,在终端输入:adb shell kill -s 9 32319(pid)
其中,-s指定发送的信号,这里9表示强制终止进程。
使用起来非常方便,但是这里有个问题,进程少了无所谓,进程多了,就要在一大串进程中查找自己要杀死的进程,就会看得眼花缭乱。
优化方法
1、把ps的查询结果,通过管道给grep查找包含特定字符串的进程。管道符“|”用来隔开两个命令,管道符左边命令的输出会作为管道符右边的输入。
root@A8-930:/ # ps | grep UCMobile ps | grep UCMobile u0_a93 445 378 1548476 67104 ffffffff f6fc2ed0 S com.UCMobile u0_a93 32739 378 1557312 74252 ffffffff f6fc2ed0 S com.UCMobile:push
这样就可以直接kill -s 9 445,杀掉UCMobile。
2、其他优化方法,在本地验证,总是显示“/system/bin/sh: killall: not found”,这里就先不列出来了。