244 lines
11 KiB
HTML
244 lines
11 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of ACCT</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>ACCT</H1>
|
|
Section: Linux Programmer's Manual (5)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
acct - process accounting file
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/sys/acct.h">sys/acct.h</A>></B>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
If the kernel is built with the process accounting option enabled
|
|
(<B>CONFIG_BSD_PROCESS_ACCT</B>),
|
|
|
|
then calling
|
|
<B><A HREF="/cgi-bin/man/man2html?2+acct">acct</A></B>(2)
|
|
|
|
starts process accounting, for example:
|
|
<P>
|
|
|
|
|
|
acct("/var/log/pacct");
|
|
|
|
<P>
|
|
|
|
When process accounting is enabled, the kernel writes a record
|
|
to the accounting file as each process on the system terminates.
|
|
This record contains information about the terminated process,
|
|
and is defined in
|
|
<I><<A HREF="file:///usr/include/sys/acct.h">sys/acct.h</A>></I>
|
|
|
|
as follows:
|
|
<P>
|
|
|
|
|
|
|
|
#define ACCT_COMM 16
|
|
<P>
|
|
typedef u_int16_t comp_t;
|
|
<P>
|
|
struct acct {
|
|
<BR> char ac_flag; /* Accounting flags */
|
|
<BR> u_int16_t ac_uid; /* Accounting user ID */
|
|
<BR> u_int16_t ac_gid; /* Accounting group ID */
|
|
<BR> u_int16_t ac_tty; /* Controlling terminal */
|
|
<BR> u_int32_t ac_btime; /* Process creation time
|
|
<BR> (seconds since the Epoch) */
|
|
<BR> comp_t ac_utime; /* User CPU time */
|
|
<BR> comp_t ac_stime; /* System CPU time */
|
|
<BR> comp_t ac_etime; /* Elapsed time */
|
|
<BR> comp_t ac_mem; /* Average memory usage (kB) */
|
|
<BR> comp_t ac_io; /* Characters transferred (unused) */
|
|
<BR> comp_t ac_rw; /* Blocks read or written (unused) */
|
|
<BR> comp_t ac_minflt; /* Minor page faults */
|
|
<BR> comp_t ac_majflt; /* Major page faults */
|
|
<BR> comp_t ac_swaps; /* Number of swaps (unused) */
|
|
<BR> u_int32_t ac_exitcode; /* Process termination status
|
|
<BR> (see <A HREF="/cgi-bin/man/man2html?2+wait">wait</A>(2)) */
|
|
<BR> char ac_comm[ACCT_COMM+1];
|
|
<BR> /* Command name (basename of last
|
|
<BR> executed command; null-terminated) */
|
|
<BR> char ac_pad[<I>X</I>]; /* padding bytes */
|
|
};
|
|
<P>
|
|
enum { /* Bits that may be set in ac_flag field */
|
|
<BR> AFORK = 0x01, /* Has executed fork, but no exec */
|
|
<BR> ASU = 0x02, /* Used superuser privileges */
|
|
<BR> ACORE = 0x08, /* Dumped core */
|
|
<BR> AXSIG = 0x10 /* Killed by a signal */
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
The
|
|
<I>comp_t</I>
|
|
|
|
data type is a floating-point value consisting of a 3-bit, base-8 exponent,
|
|
and a 13-bit mantissa.
|
|
A value,
|
|
<I>c</I>,
|
|
|
|
of this type can be converted to a (long) integer as follows:
|
|
<P>
|
|
|
|
<PRE>
|
|
v = (c & 0x1fff) << (((c >> 13) & 0x7) * 3);
|
|
</PRE>
|
|
|
|
<P>
|
|
|
|
The
|
|
<I>ac_utime</I>,
|
|
|
|
<I>ac_stime</I>,
|
|
|
|
and
|
|
<I>ac_etime</I>
|
|
|
|
fields measure time in "clock ticks"; divide these values by
|
|
<I>sysconf(_SC_CLK_TCK)</I>
|
|
|
|
to convert them to seconds.
|
|
<A NAME="lbAE"> </A>
|
|
<H3>Version 3 accounting file format</H3>
|
|
|
|
Since kernel 2.6.8,
|
|
an optional alternative version of the accounting file can be produced
|
|
if the
|
|
<B>CONFIG_BSD_PROCESS_ACCT_V3</B>
|
|
|
|
option is set when building the kernel.
|
|
With this option is set,
|
|
the records written to the accounting file contain additional fields,
|
|
and the width of
|
|
<I>c_uid</I>
|
|
|
|
and
|
|
<I>ac_gid</I>
|
|
|
|
fields is widened from 16 to 32 bits
|
|
(in line with the increased size of UID and GIDs in Linux 2.4 and later).
|
|
The records are defined as follows:
|
|
<P>
|
|
|
|
|
|
|
|
struct acct_v3 {
|
|
<BR> char ac_flag; /* Flags */
|
|
<BR> char ac_version; /* Always set to ACCT_VERSION (3) */
|
|
<BR> u_int16_t ac_tty; /* Controlling terminal */
|
|
<BR> u_int32_t ac_exitcode; /* Process termination status */
|
|
<BR> u_int32_t ac_uid; /* Real user ID */
|
|
<BR> u_int32_t ac_gid; /* Real group ID */
|
|
<BR> u_int32_t ac_pid; /* Process ID */
|
|
<BR> u_int32_t ac_ppid; /* Parent process ID */
|
|
<BR> u_int32_t ac_btime; /* Process creation time */
|
|
<BR> float ac_etime; /* Elapsed time */
|
|
<BR> comp_t ac_utime; /* User CPU time */
|
|
<BR> comp_t ac_stime; /* System time */
|
|
<BR> comp_t ac_mem; /* Average memory usage (kB) */
|
|
<BR> comp_t ac_io; /* Characters transferred (unused) */
|
|
<BR> comp_t ac_rw; /* Blocks read or written
|
|
<BR> (unused) */
|
|
<BR> comp_t ac_minflt; /* Minor page faults */
|
|
<BR> comp_t ac_majflt; /* Major page faults */
|
|
<BR> comp_t ac_swaps; /* Number of swaps (unused) */
|
|
<BR> char ac_comm[ACCT_COMM]; /* Command name */
|
|
};
|
|
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>VERSIONS</H2>
|
|
|
|
The
|
|
<I>acct_v3</I>
|
|
|
|
structure is defined in glibc since version 2.6.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
Process accounting originated on BSD.
|
|
Although it is present on most systems, it is not standardized,
|
|
and the details vary somewhat between systems.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
Records in the accounting file are ordered by termination time of
|
|
the process.
|
|
<P>
|
|
|
|
In kernels up to and including 2.6.9,
|
|
a separate accounting record is written for each thread created using
|
|
the NPTL threading library;
|
|
since Linux 2.6.10,
|
|
a single accounting record is written for the entire process
|
|
on termination of the last thread in the process.
|
|
<P>
|
|
|
|
The
|
|
<I>/proc/sys/kernel/acct</I>
|
|
|
|
file, described in
|
|
<B><A HREF="/cgi-bin/man/man2html?5+proc">proc</A></B>(5),
|
|
|
|
defines settings that control the behavior of process accounting
|
|
when disk space runs low.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+lastcomm">lastcomm</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+acct">acct</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+accton">accton</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+sa">sa</A></B>(8)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="4"><A HREF="#lbAE">Version 3 accounting file format</A><DD>
|
|
</DL>
|
|
<DT id="5"><A HREF="#lbAF">VERSIONS</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:02 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|