我想找到编程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).
更多推荐
获取最后一次重新启动的日期/时间编程
发布评论