0

I need to make a short aux bash script to clear the logcat buffer and output afterwards in a file (new process).

The problem is that at every run I need to kill the previous process which dumps in the file (but I cannot kill the entire adb process).

adb -s $1 logcat -c
adb -s $1 logcat -v time > $1.log &

$1 - the device id

I would like that the second command adb -s $1 logcat -v time > $1.log & to run in a process named $1 so I could kill it before running the other comands. Something like this:

pkill $1
adb -s $1 logcat -c
adb -s $1 logcat -v time > $1.log &
1

pkill takes a regex pattern. Use the -f option to search the whole command line.

pkill -f "adb .* $1 .* -v time"

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.