Merge pull request #1239 from lightful/pr_uptime

support uptime from Android 9+
This commit is contained in:
black 2019-05-01 13:39:10 +03:00 committed by GitHub
commit 0e8965e91b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -1216,8 +1216,14 @@ get_uptime() {
# Get uptime in seconds.
case "$os" in
"Linux" | "Windows" | "MINIX")
seconds="$(< /proc/uptime)"
seconds="${seconds/.*}"
if [[ -r /proc/uptime ]]; then
seconds="$(< /proc/uptime)"
seconds="${seconds/.*}"
else
boot="$(date -d"$(uptime -s)" +%s)"
now="$(date +%s)"
seconds="$((now - boot))"
fi
;;
"Mac OS X" | "iPhone OS" | "BSD" | "FreeMiNT")