Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get log just for last 5 minutes from command line

How to get log for recent time, for example, for last 5 minutes?

This command in command line

adb logcat -v time | find "E/"

gives error logs for all time.

(It's not interesting to wait several minutes while all logs is displaying)

Thank you very much!

like image 204
Kiryl Ivanou Avatar asked Oct 28 '25 05:10

Kiryl Ivanou


1 Answers

adb logcat -T "$(date +'%m-%d %H:%M:%S.%q' -d '5 minutes ago')"

Caveats:

  • Uses time from host system, not device so if there is drift you have to correct for it
  • Requires a POSIX shell and date command (works on Linux and Mac, not sure windows)
like image 111
Eric Drechsel Avatar answered Oct 31 '25 01:10

Eric Drechsel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!