xref: /freebsd/usr.sbin/ac/ac.8 (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
1.\"
2.\" Copyright (c) 1994 Simon J. Gerraty
3.\" Copyright (c) 1994 Christopher G. Demetriou
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.Dd February 14, 2020
27.Dt AC 8
28.Os
29.Sh NAME
30.Nm ac
31.Nd connect time accounting
32.Sh SYNOPSIS
33.Nm
34.Op Fl dp
35.\".Op Fl c Ar console
36.Op Fl t Ar tty
37.Op Fl w Ar wtmp
38.Op Ar users ...
39.Sh DESCRIPTION
40If the file
41.Pa /var/log/utx.log
42exists, a record of individual login and logout
43times are written to it by
44.Xr login 1
45and
46.Xr init 8 ,
47respectively.
48The
49.Nm
50utility
51examines these records and writes the accumulated connect time (in hours)
52for all logins to the standard output.
53.Pp
54The options are as follows:
55.Bl -tag -width indentXXX
56.It Fl d
57Display the connect times in 24 hour chunks.
58.\" .It Fl c Ar console
59.\" Use
60.\" .Ar console
61.\" as the name of the device that local X sessions (ut_host of ":0.0")
62.\" originate from.  If any login has been recorded on
63.\" .Ar console
64.\" then these X sessions are ignored unless COMPAT_SUNOS was defined at
65.\" compile time.
66.It Fl p
67Print individual users' totals.
68.It Fl t Ar tty
69Only do accounting logins on certain ttys.
70The
71.Ar tty
72specification can start with '!' to indicate not this
73.Ar tty
74and end with '*' to indicate all similarly named ttys.
75Multiple
76.Fl t
77flags may be specified.
78.It Fl w Ar wtmp
79Read connect time data from
80.Ar wtmp
81instead of the default file,
82.Pa /var/log/utx.log .
83.It Ar users ...
84Display totals for the given individuals only.
85.El
86.Pp
87If no arguments are given,
88.Nm
89displays the total connect time for all
90accounts with login sessions recorded in
91.Pa utx.log .
92.Pp
93The default
94.Pa utx.log
95file will increase without bound unless it is truncated.
96It is normally truncated by the daily scripts run
97by
98.Xr cron 8 ,
99which rename and rotate the
100.Pa utx.log
101files, keeping a week's worth of data on
102hand.
103No login or connect time accounting is performed if
104.Pa /var/log/utx.log
105does not exist.
106.Sh FILES
107.Bl -tag -width /var/log/utx.log -compact
108.It Pa /var/log/utx.log
109connect time accounting file
110.El
111.Sh EXIT STATUS
112.Ex -std
113.Sh EXAMPLES
114Allow times recorded in
115.Pa modems
116to be charged out at a different rate than
117.Pa other :
118.Bd -literal -offset indent
119ac -p -t "ttyd*" > modems
120ac -p -t "!ttyd*" > other
121.Ed
122.Sh SEE ALSO
123.Xr login 1 ,
124.Xr getutxent 3 ,
125.Xr init 8 ,
126.Xr sa 8
127.Sh HISTORY
128An
129.Nm
130command appeared in
131.At v5 .
132This version of
133.Nm
134was written for
135.Nx 0.9a
136from the specification provided by various systems' manual pages.
137.\" .Sh NOTES
138.\" If COMPAT_SUNOS is defined
139.\" .Nm ac
140.\" ignores the fact that entries with ut_host of ":0.0" are not real
141.\" login sessions.  Normally such entries are ignored except in the case
142.\" of a user being logged in when the
143.\" .Pa wtmp
144.\" file was rotated, in which case a login with ut_host of ":0.0" may
145.\" appear without any preceding console logins.
146.\" If no one is logged in on the console, the user is deemed to have
147.\" logged in on at the earliest time stamp found in
148.\" .Pa wtmp .
149.\" Use of
150.\" .Pa console
151.\" allows
152.\" .Nm ac
153.\" to identify and correctly process a logout for the user.  The default
154.\" value for
155.\" .Pa console
156.\" is usually correct at compile time.
157