#include <stdio.h>
#include <stdlib.h>
#include <utmpx.h>
#include <time.h>

int
main(int argc, char *argv[])
{
    char buf[20];
    struct utmpx *ut;
    struct tm *tm;
    time_t t;

    setutxent();
    while ((ut = getutxent()) != NULL) {
        if (ut->ut_type != USER_PROCESS)
            continue;

        t = ut->ut_tv.tv_sec;
        tm = localtime(&t);

        strftime(buf, 30, "%Y-%m-%d %H:%M", tm);

        printf("%-8s ", ut->ut_user);
        printf("%-12s %s\n", ut->ut_line, buf);
    }
    endutxent();
}
