1 .\" Copyright (C) 2008, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .TH acct 5 (date) "Linux man-pages (unreleased)"
7 acct \- process accounting file
10 .B #include <sys/acct.h>
13 If the kernel is built with the process accounting option enabled
14 .RB ( CONFIG_BSD_PROCESS_ACCT ),
17 starts process accounting, for example:
20 acct("/var/log/pacct");
23 When process accounting is enabled, the kernel writes a record
24 to the accounting file as each process on the system terminates.
25 This record contains information about the terminated process,
34 typedef u_int16_t comp_t;
37 char ac_flag; /* Accounting flags */
38 u_int16_t ac_uid; /* Accounting user ID */
39 u_int16_t ac_gid; /* Accounting group ID */
40 u_int16_t ac_tty; /* Controlling terminal */
41 u_int32_t ac_btime; /* Process creation time
42 (seconds since the Epoch) */
43 comp_t ac_utime; /* User CPU time */
44 comp_t ac_stime; /* System CPU time */
45 comp_t ac_etime; /* Elapsed time */
46 comp_t ac_mem; /* Average memory usage (kB) */
47 comp_t ac_io; /* Characters transferred (unused) */
48 comp_t ac_rw; /* Blocks read or written (unused) */
49 comp_t ac_minflt; /* Minor page faults */
50 comp_t ac_majflt; /* Major page faults */
51 comp_t ac_swaps; /* Number of swaps (unused) */
52 u_int32_t ac_exitcode; /* Process termination status
54 char ac_comm[ACCT_COMM+1];
55 /* Command name (basename of last
56 executed command; null\-terminated) */
57 char ac_pad[\fIX\fP]; /* padding bytes */
60 enum { /* Bits that may be set in ac_flag field */
61 AFORK = 0x01, /* Has executed fork, but no exec */
62 ASU = 0x02, /* Used superuser privileges */
63 ACORE = 0x08, /* Dumped core */
64 AXSIG = 0x10 /* Killed by a signal */
71 data type is a floating-point value consisting of a 3-bit, base-8 exponent,
72 and a 13-bit mantissa.
75 of this type can be converted to a (long) integer as follows:
78 v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3);
86 fields measure time in "clock ticks"; divide these values by
87 .I sysconf(_SC_CLK_TCK)
88 to convert them to seconds.
89 .SS Version 3 accounting file format
91 an optional alternative version of the accounting file can be produced
93 .B CONFIG_BSD_PROCESS_ACCT_V3
94 option is set when building the kernel.
95 With this option is set,
96 the records written to the accounting file contain additional fields,
101 fields is widened from 16 to 32 bits
102 (in line with the increased size of UID and GIDs in Linux 2.4 and later).
103 The records are defined as follows:
108 char ac_flag; /* Flags */
109 char ac_version; /* Always set to ACCT_VERSION (3) */
110 u_int16_t ac_tty; /* Controlling terminal */
111 u_int32_t ac_exitcode; /* Process termination status */
112 u_int32_t ac_uid; /* Real user ID */
113 u_int32_t ac_gid; /* Real group ID */
114 u_int32_t ac_pid; /* Process ID */
115 u_int32_t ac_ppid; /* Parent process ID */
116 u_int32_t ac_btime; /* Process creation time */
117 float ac_etime; /* Elapsed time */
118 comp_t ac_utime; /* User CPU time */
119 comp_t ac_stime; /* System time */
120 comp_t ac_mem; /* Average memory usage (kB) */
121 comp_t ac_io; /* Characters transferred (unused) */
122 comp_t ac_rw; /* Blocks read or written
124 comp_t ac_minflt; /* Minor page faults */
125 comp_t ac_majflt; /* Major page faults */
126 comp_t ac_swaps; /* Number of swaps (unused) */
127 char ac_comm[ACCT_COMM]; /* Command name */
132 Although it is present on most systems, it is not standardized,
133 and the details vary somewhat between systems.
139 Process accounting originated on BSD.
141 Records in the accounting file are ordered by termination time of
144 Up to and including Linux 2.6.9,
145 a separate accounting record is written for each thread created using
146 the NPTL threading library;
148 a single accounting record is written for the entire process
149 on termination of the last thread in the process.
152 .I /proc/sys/kernel/acct
155 defines settings that control the behavior of process accounting
156 when disk space runs low.