Use Shell to differentiate Android soft hard reboot problem

Source: Internet
Author: User
Tags current time time interval

Uptime command:
-* Use the uptime command to get host run time and query Linux system load information. The information is displayed in the following order: Now time, the system has elapsed time, the current number of landing users, the system in the past 1 minutes, 5 minutes and 15 minutes of the average load. *

ubuntu@ubuntu:~$ Uptime
17:42:05 up 3 days, 7:58, 6 users, load average:0.11, 0.10, 0.11
17:42:05//System Current time
Up to 3 days, 7:58//host has run time, the greater the time, indicating the stability of the host
6 user//connection number, total number of connections instead of number of users
Load average*//System average load, statistic last 1, 5, 15 min system average load, system average load is the average number of processes running in a queue at a specific time interval.
The solution method thought:

Record the Sys_pid_before,reboot_before before the test, and record the sys_pid_after,reboot_after after the test.
If [$ ((reboot_after-reboot_before))-GT 10] | | [$sys _pid_before-ne $sys _pid_after] is considered a soft reboot of Android
If [$ ((reboot_after-reboot_before))-GT 10] is established, it is considered an android hard reboot

' SYS_PID_AFTER=ADB shell PS System_server|awk ' nr==2{print $} '

date= ' adb shell date +%s|grep-o ' ^[0-9].*[0-9] '

Uptime= ' adb shell cat/proc/uptime|awk-f ' {print $} '

reboot_after= ' Expr date−uptime '

Sys_pid_before= $sys _pid_after

Reboot_before= $reboot _after

If [$ ((reboot_after-reboot_before))-GT 10] | | [$sys _pid_before-ne $sys _pid_after]; Then
Echo ==========system_server reboot==========
If [$ (reboot_after-reboot_before))-gt];then
Echo ==========kernel panics==========
Fi
Hi.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.