xref: /freebsd/share/man/man5/acct.5 (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1.\" Copyright (c) 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)acct.5	8.1 (Berkeley) 6/5/93
33.\" $FreeBSD$
34.\"
35.Dd May 15, 2007
36.Dt ACCT 5
37.Os
38.Sh NAME
39.Nm acct
40.Nd execution accounting file
41.Sh SYNOPSIS
42.In sys/types.h
43.In sys/acct.h
44.Sh DESCRIPTION
45The kernel maintains the following
46.Fa acct
47information structure for all
48processes.
49If a process terminates, and accounting is enabled,
50the kernel calls the
51.Xr acct 2
52function call to prepare and append the record
53to the accounting file.
54.Bd -literal
55#define AC_COMM_LEN 16
56
57/*
58 * Accounting structure version 2 (current).
59 * The first byte is always zero.
60 * Time units are microseconds.
61 */
62
63struct acctv2 {
64	uint8_t  ac_zero;		/* zero identifies new version */
65	uint8_t  ac_version;		/* record version number */
66	uint16_t ac_len;		/* record length */
67
68	char	  ac_comm[AC_COMM_LEN];	/* command name */
69	float	  ac_utime;		/* user time */
70	float	  ac_stime;		/* system time */
71	float	  ac_etime;		/* elapsed time */
72	time_t	  ac_btime;		/* starting time */
73	uid_t	  ac_uid;		/* user id */
74	gid_t	  ac_gid;		/* group id */
75	float	  ac_mem;		/* average memory usage */
76	float	  ac_io;		/* count of IO blocks */
77	__dev_t   ac_tty;		/* controlling tty */
78
79	uint16_t ac_len2;		/* record length */
80	union {
81		__dev_t	  ac_align;	/* force v1 compatible alignment */
82
83#define	AFORK	0x01			/* forked but not exec'ed */
84/* ASU is no longer supported */
85#define	ASU	0x02			/* used super-user permissions */
86#define	ACOMPAT	0x04			/* used compatibility mode */
87#define	ACORE	0x08			/* dumped core */
88#define	AXSIG	0x10			/* killed by a signal */
89#define ANVER	0x20			/* new record version */
90
91		uint8_t  ac_flag;	/* accounting flags */
92	} ac_trailer;
93
94#define ac_flagx ac_trailer.ac_flag
95};
96.Ed
97.Pp
98If a terminated process was created by an
99.Xr execve 2 ,
100the name of the executed file (at most ten characters of it)
101is saved in the field
102.Fa ac_comm
103and its status is saved by setting one of more of the following flags in
104.Fa ac_flag :
105.Dv AFORK ,
106.Dv ACOMPAT ,
107.Dv ACORE
108and
109.Dv ASIG .
110.Dv ASU
111is no longer supported.
112.Dv ANVER
113is always set in the above structure.
114.Sh SEE ALSO
115.Xr lastcomm 1 ,
116.Xr acct 2 ,
117.Xr execve 2 ,
118.Xr sa 8
119.Sh HISTORY
120A
121.Nm
122file format appeared in
123.At v7 .
124The current record format was introduced on May 2007.
125It is backwards compatible with the previous format,
126which is still documented in
127.In sys/acct.h
128and supported by
129.Xr lastcomm 1
130and
131.Xr sa 8 .
132