1五、linux中last命令显示年份信息

#include <stdio.h>ide

#include <utmp.h>get

#include <string.h>string

#include <time.h>it


int main(void) {io

        struct utmp *line;编译

        time_t timestamp;ast

        utmpname("/var/log/wtmp");class

        setutent();gcc

        while( (line = getutent()) != NULL) {gc

                if (line->ut_type == USER_PROCESS ) {

                        timestamp = line->ut_tv.tv_sec;

                        printf("%s %s %s %s", line->ut_user, line->ut_line,line->ut_host, asctime(localtime(&timestamp)));

                }

        }

        endutent();

        return 0;

}


编译生成执行命令

gcc -Wall last.c -o last


执行

./last

相关文章
相关标签/搜索