Enable accounting and view system usage statistics
Author: name contact BSD flavour
Reviewer: name contact BSD flavour
Reviewer: name contact BSD flavour
Concept
Be aware of when it is appropriate to enable system accounting, recognize which utilities are available to do so, and know how to view the resulting statistics.
Introduction
The kernel keeps track of various attributes of all processes and, when system accounting (((accounting))) (((system accounting))) is enabled, this information is saved when the process terminates. The accounting information includes the command name, the starting time, the amount of time used by the system and the user (TODO: explain that), the elapsed time, the user ID and group ID, the average amount of memory used, the count of I/O operations, and the terminal (((terminal))) (tty) (((tty))) where the process was started. The accounting also records if the process was forked without replacing the parent process (exec) and how the process was terminated (such as with core dump or killed by a signal).
The system accounting is enabled by running the accton command with the path to the file to store the data as the argument, commonly at
/var/account/acct.
System accounting is turned off by running accton without any arguments.
TODO: show how is enabled at boot time on all BSDs
TODO: show example of data; show examples of sa, ac, accton, lastcomm
TODO: not the same, but also cover "last"
Examples
Practice Exercises
More information
ac(8), sa(8), accton(8), lastcomm(1), last(1)