使用adb抓取logcat时,如何杀掉logcat进程问题,有两种方法:第一种杀电脑端进程,第二种杀手机端进程
一、啥电脑端进程
taskkill /F /T /PID {p.pid}
p = subprocess.Popen(f"adb -s {device} logcat >{device}.txt", shell=True)
time.sleep(10)
subprocess.Popen(f"taskkill /F /T /PID {p.pid}", shell=True)
二、杀手机端进程
- 查找进程号
adb shell ps |findstr “logcat” - kill进程
adb shell kill -9 {pid}
以下是threading作业
import os, threading, time
# 获取device id,返回device list
def get_device_list():
devices_lines = os.popen("adb devices").readlines()
devices = []
for line in devices_lines[1:-1]:
devices.append(line.split('\t')[0])
return devices
# 获取logcat pid, 返回pid list
def get_logcat_pids(pid_lines):
pids = []
for line in pid_lines:
if line.startswith('shell'):
pid = list(filter(None, line.split(&