To view system uptime and load, use the uptime command
$ uptime 11:23:24 up 2:18, 3 users, load average:0.00, 0.01, 0.05
For uptime commands please refer to http://blog.csdn.net/u011641885/article/details/46638521
View/proc/uptime file calculation system start time
$ cat/proc/uptime 8565.04 8236.71 The first value represents the total elapsed time of the system, and the second value represents the time the system is idle, expressed in seconds. If the second number in the system is larger than the first number, it means that your CPU is multicore, cpu0 on a second, cpu1 on the idle for two seconds, add up is three seconds.
As a result, the system startup time can be calculated using the date command.
Date-d "$ (awk-f. ' {print '} '/proc/uptime) second ago" + "%y-%m-%d%h:%m:%s" date-d//Displays the time described in the specified string. date-d "Number second ago" + "%y-%m-%d%h:%m:%s"//number seconds before the time, in%y-%m-%d%h:%m:%s format display
For more instructions on date-d, refer to http://blog.csdn.net/u011641885/article/details/46646283
Viewing the/proc/uptime file can also calculate the system run time
The command is as follows:
cat/proc/uptime| Awk-f. ' {run_days=$1/86400;run_hour= ($ 86400)/3600;run_minute= ($ 3600)/60;run_second=$1% 60;printf ("system has been running:%d days% D at%d seconds ", Run_days,run_hour,run_minute,run_second)} '
The script is as follows:
#!/bin/bashsumtime= ' Awk-f ' {print $ '/proc/uptime ' day= ' echo $[$SUMTIME/86400] ' hour= ' echo $[$SUMTIME% 86400/3600] ' Minute= ' echo $[$SUMTIME% 3600/60] ' second= ' echo $[$SUMTIME%] ' printf ' $DAY day $HOUR: $MINUTE: $SECOND \ n "
Get Linux system uptime and system startup time