xref: /openbsd/usr.sbin/ac/ac.8 (revision 09467b48)
1.\"	$OpenBSD: ac.8,v 1.23 2020/02/08 01:43:22 jsg Exp $
2.\"
3.\" Copyright (c) 1994 Simon J. Gerraty
4.\" Copyright (c) 1994 Christopher G. Demetriou
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"      This product includes software developed by Christopher G. Demetriou.
18.\" 3. The name of the author may not be used to endorse or promote products
19.\"    derived from this software without specific prior written permission
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
32.Dd $Mdocdate: February 8 2020 $
33.Dt AC 8
34.Os
35.Sh NAME
36.Nm ac
37.Nd connect time accounting
38.Sh SYNOPSIS
39.Nm ac
40.Op Fl dp
41.Op Fl t Ar tty
42.Op Fl w Ar wtmp
43.Op Ar user ...
44.Sh DESCRIPTION
45If the file
46.Pa /var/log/wtmp
47exists, a record of individual login and logout
48times are written to it by
49.Xr login 1
50and
51.Xr init 8 ,
52respectively.
53.Nm
54examines these records and writes the accumulated connect time
55for all logins to the standard output.
56.Pp
57The options are as follows:
58.Bl -tag -width Ds
59.It Fl d
60Display the connect times in 24 hour chunks.
61.It Fl p
62Print individual users' totals.
63.It Fl t Ar tty
64Only do accounting logins on certain ttys.
65The
66.Ar tty
67specification can start with
68.Ql \&!
69to indicate not this
70.Ar tty
71and end with
72.Ql *
73to indicate all similarly named ttys.
74Multiple
75.Fl t
76flags may be specified.
77.It Fl w Ar wtmp
78Read connect time data from
79.Ar wtmp
80instead of the default file,
81.Pa /var/log/wtmp .
82.It Ar user ...
83Display totals for the given individuals only.
84.El
85.Pp
86If no arguments are given,
87.Nm
88displays the total connect time for all
89accounts with login sessions recorded in
90.Xr wtmp 5 .
91.Pp
92The default
93.Pa wtmp
94file will increase without bound unless it is truncated.
95It is normally truncated by
96.Xr newsyslog 8 ,
97which renames and rotates the
98.Pa wtmp
99files every week.
100In order for
101.Nm
102to run in sync with the rotation of
103.Pa wtmp ,
104.Xr newsyslog 8
105is configured to run
106just after
107.Nm
108completes.
109.Pp
110User accounting information can be mailed weekly
111to the system administrator:
112see
113.Xr weekly 8
114for more information.
115No login or connect time accounting is performed if
116.Pa /var/log/wtmp
117does not exist.
118.Sh FILES
119.Bl -tag -width "/var/log/wtmp.[0-7]XX" -compact
120.It Pa /var/log/wtmp
121connect time accounting file
122.It Pa /var/log/wtmp.[0-7]
123rotated files
124.El
125.Sh EXIT STATUS
126.Ex -std ac
127.Sh EXAMPLES
128Allow times recorded in
129.Pa modems
130to be charged out at a different rate than
131.Pa other :
132.Bd -literal -offset indent
133$ ac -p -t "ttyd*" \*(Gt modems
134$ ac -p -t "!ttyd*" \*(Gt other
135.Ed
136.Sh SEE ALSO
137.Xr login 1 ,
138.Xr wtmp 5 ,
139.Xr cron 8 ,
140.Xr init 8 ,
141.Xr newsyslog 8 ,
142.Xr sa 8
143.Sh HISTORY
144An
145.Nm
146command appeared in
147.At v5 .
148This version of
149.Nm
150was written for
151.Nx 0.9a
152from the specification provided by various systems' manual pages.
153