linuxc获取系统关机时间

作者: mg4355  发布:2020-01-03

linuxc获取系统关机时间

源码如下:

#include 
#include 
#include 
#include 


int main()
{
    struct utmp *u ;
    FILE *fp = fopen("shutdown_note","w+");
    utmpname("/var/log/wtmp");
    while((u = getutent()))
    {
        if(strncmp(u->ut_user,"shutdown",8) == 0)
            fprintf(fp," %s time: %s", u->ut_user, ctime((time_t *)(&u->ut_tv.tv_sec)));
    }

    endutent();

   return 0;

}

源码如下: #include #include #include #include int main(){ struct utmp *u ; FILE *fp = fopen(shutdown_note,w+); utmpname(/var/log/wtmp); while((...

本文由mg4355娱乐手机版发布于mg4355,转载请注明出处:linuxc获取系统关机时间

关键词: