NOTE: APAR IX42292 corrects this problem in AIX 3.2.5. The problem was corrected in AIX 3.2.5.1 and all later releases.
10 23 * * 0-6 /usr/lib/acct/runacct 2>/usr/adm/acct/nite/accterr > /dev/nullEdit the adm crontab with the command su adm -c crontab -e and change that line to read:
10 23 * * 0-6 (/usr/lib/acct/runacct ;/usr/lib/acct/mkwtmp) 2>/usr/adm/acct/nite/accterr> /dev/nullNow you're ready to run the C program.
Depending on how you are viewing this document, some characters in the following code may appear incorrectly. If the characters in the following list do not match their descriptions, be sure to change them in the code.
[ | left bracket |
] | right bracket |
#include#include #include main (int argc, char ** argv) { char *utmp_name = "/etc/utmp"; char *wtmp_name = "/var/adm/wtmp"; FILE *utmp_fp = 0; FILE *wtmp_fp = 0; int flag; time_t now; struct utmp utmp_rec; extern int optind; extern char *optarg; while ((flag = getopt (argc, argv, "u:w:")) != EOF) { switch (flag) { case 'u': utmp_name = optarg; break; case 'w': wtmp_name = optarg; break; default: fprintf (stderr, "mkwtmp [ -u utmp ] [ -w wtmp ]\n"); exit (0); break; } } if ((utmp_fp = fopen (utmp_name, "r")) == (FILE *) 0) { perror (utmp_name); exit (1); } if ((wtmp_fp = fopen (wtmp_name, "w")) == (FILE *) 0) { perror (wtmp_name); exit (1); } time (&now); while (fread (&utmp_rec, sizeof utmp_rec, 1, utmp_fp) == 1) { if (utmp_rec.ut_type == USER_PROCESS) { utmp_rec.ut_time = now; fwrite (&utmp_rec, sizeof utmp_rec, 1, wtmp_fp); } } exit (0); }