|
- who -b 查看最后一次系统启动的时间。
- who -r 查看当前系统运行时间
- last reboot
- uptime
复制代码- cat /proc/uptime
- date -d "`cut -f1 -d. /proc/uptime` seconds ago"
- date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S"
复制代码- Following are the rest of the time function in the above perl code-snippet.
- ■$total=((($1*24+$2)*60+$3)*60) – Calculate the total amount of seconds the system is UP. i.e (((days*24+hours)*60+minutes)*60 which gives the seconds (like an epoch calculation)
- ■$now=time(); – Get the current time in seconds ( epoch time )
- ■$now-=$total; – Subtract total system running time from current time. So this is getting the exact time in second when the system was started
- ■$now=localtime($now); – Convert the epoch time ( time in seconds ). localtime returns given epoch time in human readable format
- ■print $now,”\n” – Finally, this prints the time.
复制代码 http://www.cnblogs.com/kerrycode/p/3759395.html
http://www.averainy.info/linux-system-operation-time-and-the-view-of-the-latest-powered-up-time/
http://www.thegeekstuff.com/2011/10/linux-reboot-date-and-time |
|