获取最后一次重新启动的日期/时间编程 [英] Get date/time of last reboot programmatically
本文介绍了获取最后一次重新启动的日期/时间编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想找到编程Linux中的最后重新启动的时间。我是我的模块中使用C和C ++。
I would like to find the time of the last reboot programmatically in Linux. I am using C and C++ in my module.
是否有一个API?
推荐答案
有没有直接的API,但你可以阅读的/ proc /运行时间
文件,以了解有多少该系统已经运行秒,减,从目前的时间 - 并承担时,机器重新启动后的
There's no direct api, but you can read /proc/uptime
"file" to learn how many seconds the system have been running, subtract that from the current time - and assume that's when the machine was rebooted.
的/ proc /运行时间
此文件包含两个数字:该系统的正常运行时间
(秒),和的时间量
在度过空闲进程(秒)。
/proc/uptime This file contains two numbers: the uptime of the system (seconds), and the amount of time spent in idle process (seconds).
这篇关于获取最后一次重新启动的日期/时间编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文