OSX:以编程方式获得正常运行时间? [英] OSX: programmatically get uptime?

查看:107
本文介绍了OSX:以编程方式获得正常运行时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似于linux

cat /proc/uptime

以秒为单位返回正常运行时间,最好不解析正常运行时间(1).

which returns the uptime in seconds, and preferably not parsing uptime(1).

推荐答案

有关Wikipedia的正常运行时间文章有一个有趣的线索:

The Uptime article on Wikipedia has an interesting lead:

使用sysctl

还有一种使用sysctl的方法 调用系统的最后启动 时间:$ sysctl kern.boottime kern.boottime:{秒= 1271934886, usec = 667779}周四4月22日12:14:46 2010

There is also a method of using sysctl to call the system's last boot time: $ sysctl kern.boottime kern.boottime: { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46 2010

哪些参考文献 sysctl(8) ,其中引用

Which references sysctl(8), which references sysctl(3).

这篇关于OSX:以编程方式获得正常运行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆