获取最后一次重新启动的日期/时间编程

编程入门 行业动态 更新时间:2024-10-28 10:23:45
本文介绍了获取最后一次重新启动的日期/时间编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想找到编程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).

更多推荐

获取最后一次重新启动的日期/时间编程

本文发布于:2023-10-23 01:32:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519341.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   日期   时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!