0

I connect all our android devices through adb with WiFi. I am trying to get the uptime in hour. what i got now is in seconds.

adb connect 172.16.100.2
adb shell cat /proc/uptime > "C:\TimeLog.txt"
(or just adb shell uptime)
adb disconnect

The result is

258521.25 1019421.93
(or uptime: 2 days, 23:59:00, idle time: 11 days.....)

All I need is uptime in hour, I dont need 2nd part of time...

I also tried

adb shell awk '{print int($1/3600)":"int(($1%3600)/60)":"int($1%60)}' /proc/uptime

But /system/bin/sh: aws: not found

What else i can use with adb or shell on Android for getting uptime?

Also what command should i use to setup date/time on Android?

Root Loop
  • 3,004
  • 9
  • 46
  • 72
  • Is this question actually related to programming? – Squonk Mar 09 '15 at 17:26
  • I think so, it is kind of Android shell script.... If it is not, i can remove the post... – Root Loop Mar 09 '15 at 17:30
  • Stack Overflow is a programmers Q&A site in the sense that questions should generally relate to software that someone is developing but is having trouble with errors / crashes etc. Your question is about running an Android SDK tool from a Windows command prompt to query system info on devices. It might be better suited to http://android.stackexchange.com – Squonk Mar 09 '15 at 17:39
  • if you are ok with not having leading zeroes for single digit values - `U=$(cat /proc/uptime);U=${U%%.*};H=$((U/3600));M=$((U%3600));M=$((M/60));S=$((U%60));echo $H:$M:$S` – Alex P. Mar 09 '15 at 19:14
  • Thanks , I just use `adb shell uptime`, that's it. no more headache.... – Root Loop Mar 09 '15 at 19:51

1 Answers1

1

I am pretty sure that awk is not part of the default android installation. If you run linux you can use:

adb shell cat /proc/uptime | awk ...

joecks
  • 4,539
  • 37
  • 48
  • I am running adb on windows...I could output everything first then filter from there but I wondering if there is any Android command that i can do it in one shot. – Root Loop Mar 09 '15 at 17:23
  • I think you are out of luck here since by default android uses shell by default. You could try this as a starter but it does not work with floating points: ` set \`cat /proc/uptime\` ; echo $(($1/3600))` – joecks Mar 09 '15 at 17:42