7

I am trying to run logcat in background using adb.

adb shell "logcat -r 2000 -f /data/local/test.log &"

But it does not work. If I do adb shell ps | grep logcat I dont see logcat process running.

2 Answers 2

11

Adding nohup seems to work.
adb shell "nohup logcat -r 2000 -f /data/local/test.log &"

Sign up to request clarification or add additional context in comments.

6 Comments

I get /system/bin/sh: nohup: not found. And, from the command line, I need to put the -f option first, otherwise I get an error.
I get nohup not found either. Any ideas? I'm on the Nexus 5.
Try 'daemoonize' if 'nohup' is not found. See stackoverflow.com/a/10039155/82180
@trusktr it's not normal (default) to have nohup on Android from my experience. I think people are talking rooted systems typically. You can download busybox and use it even on non-rooted systems.. works perfectly fine. busybox had "nohup" in it. I suggest a new question for "how do I setup latest busybox on android via adb shell"...
FWIW, on many device this will run until the device is disconnected from USB. Then app processes are killed. Reproduced on LG V30, Fire tablet and Huawei P40 Lite E. Works perfectly on S10+ Android 10 or Pixel 3 XL Android 11. Still haven't found a way to make the process survive disconnecting.
|
1

If you can't run nohup directly, then you could try this: busybox nohup logcat

BusyBox combines tiny versions of many common UNIX utilities into a single small executable. So it has nohup feature as well and you could use it via busybox if manufacturer turns nohup option on at compile time.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.