[ Team LiB ] |
Recipe 9.39 Displaying All Executed Commands9.39.1 ProblemYou want to display information about executed commands, as recorded by process accounting. 9.39.2 SolutionTo view the latest accounting information: $ lastcomm [command-name] [user-name] [terminal-name] To view the complete record using lastcomm: # umask 077 Avoid publicly-readable accounting data in /var/tmp # zcat `ls -tr /var/account/pacct.*.gz` > /var/tmp/pacct # cat /var/account/pacct >> /var/tmp/pacct # lastcomm -f /var/tmp/pacct # rm /var/tmp/pacct For more detailed information: # dump-acct [--reverse] /var/account/pacct 9.39.3 DiscussionThe GNU accounting utilities are a collection of programs for viewing the audit trail. The most important is lastcomm, which prints the following information for each process:
Information about commands is listed in reverse chronological order, as determined by the time when each process exited (which is when the kernel writes the accounting records). Commands can be selected by combinations of the command name, user, or terminal; see lastcomm(1) for details. lastcomm can read an alternative log file with the -f option, but it cannot read from a pipe, because it needs to seek within the accounting file, so the following will not work: Fails: $ zcat pacct.gz | lastcomm -f /dev/stdin The kernel records much more information than is displayed by lastcomm. The undocumented dump-acct command prints more detailed information for each process:
Red Hat 8.0 kernels increased HZ to 512 for better time resolution, with a correspondingly shorter tick. The tickadj command prints the current value of the tick, in microseconds: $ tickadj tick = 10000 By default, dump-acct lists commands in chronological order; use the -r or —reverse options for behavior similar to lastcomm. One or more accounting files must be explicitly specified on the command line for dump-acct. 9.39.4 See Alsolastcomm(1). |
[ Team LiB ] |