首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linux获取开机后的系统时间

Linux获取开机后的系统时间
EN

Stack Overflow用户
提问于 2013-07-18 23:46:16
回答 3查看 9.7K关注 0票数 3

我需要找到系统时间,因为电源是在我的c代码中的linux机器上使用的。像' time ()‘和gettimeofday()这样的函数返回的是自纪元以来的时间,而不是通电以来的时间。如何查找开机后的时间或时钟滴答数?

提前感谢!

EN

Stack Overflow用户

发布于 2013-07-18 23:50:34

请参阅:Wgat API do I call to get the System Time

请参阅中的sysinfo

sys/sysinfo.h

代码语言:javascript
复制
struct sysinfo {
  long uptime;             /* Seconds since boot */
  unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
  unsigned long totalram;  /* Total usable main memory size */
  unsigned long freeram;   /* Available memory size */
  unsigned long sharedram; /* Amount of shared memory */
  unsigned long bufferram; /* Memory used by buffers */
  unsigned long totalswap; /* Total swap space size */
  unsigned long freeswap;  /* swap space still available */
  unsigned short procs;    /* Number of current processes */
  unsigned long totalhigh; /* Total high memory size */
  unsigned long freehigh;  /* Available high memory size */
  unsigned int mem_unit;   /* Memory unit size in bytes */
  char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */
};
票数 3
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17728173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档