如何从proc文件中获取系统时间?

fly*_*pen 3 linux procfs

如何从proc文件中获取系统时间?我知道我们可以从日期等命令中获取系统时间,也可以根据时间API编写一些代码.但我真的需要使用一个简单的proc文件来获取时间.无论时间格式是什么,简单的值都可以.例如,从1970/1/1开始的总秒数非常好.

小智 12

是的你可以 :

cat /proc/driver/rtc
Run Code Online (Sandbox Code Playgroud)

来自男人:

RTC vs system clock
   RTCs should not be confused with the system clock, which is a
   software clock maintained by the kernel and used to implement
   gettimeofday(2) and time(2), as well as setting timestamps on files,
   and so on.  The system clock reports seconds and microseconds since a
   start point, defined to be the POSIX Epoch: 1970-01-01 00:00:00 +0000
   (UTC).
Run Code Online (Sandbox Code Playgroud)

更多这里