xref: /freebsd/usr.sbin/ac/ac.8 (revision 2362d22e487e8971dcc7add6bd84ee37fe542c05)
1ff9c3a32SDavid Greenman.\"
2ff9c3a32SDavid Greenman.\" Copyright (c) 1994 Simon J. Gerraty
3ff9c3a32SDavid Greenman.\" Copyright (c) 1994 Christopher G. Demetriou
4ff9c3a32SDavid Greenman.\" All rights reserved.
5dea673e9SRodney W. Grimes.\"
6dea673e9SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
7dea673e9SRodney W. Grimes.\" modification, are permitted provided that the following conditions
8dea673e9SRodney W. Grimes.\" are met:
9dea673e9SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
10dea673e9SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
11dea673e9SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
12dea673e9SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
13dea673e9SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
14dea673e9SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
15dea673e9SRodney W. Grimes.\"    must display the following acknowledgement:
16ff9c3a32SDavid Greenman.\"      This product includes software developed by Christopher G. Demetriou.
17ff9c3a32SDavid Greenman.\" 3. The name of the author may not be used to endorse or promote products
18ff9c3a32SDavid Greenman.\"    derived from this software without specific prior written permission
19dea673e9SRodney W. Grimes.\"
20ff9c3a32SDavid Greenman.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21ff9c3a32SDavid Greenman.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22ff9c3a32SDavid Greenman.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23ff9c3a32SDavid Greenman.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24ff9c3a32SDavid Greenman.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25ff9c3a32SDavid Greenman.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26ff9c3a32SDavid Greenman.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27ff9c3a32SDavid Greenman.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28ff9c3a32SDavid Greenman.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29ff9c3a32SDavid Greenman.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30dea673e9SRodney W. Grimes.\"
312362d22eSJoerg Wunsch.\"	$Id: ac.8,v 1.2 1994/09/26 22:12:25 davidg Exp $
32dea673e9SRodney W. Grimes.\"
33ff9c3a32SDavid Greenman.Dd March 15, 1994
34dea673e9SRodney W. Grimes.Dt AC 8
35ff9c3a32SDavid Greenman.Os
36dea673e9SRodney W. Grimes.Sh NAME
37dea673e9SRodney W. Grimes.Nm ac
38ff9c3a32SDavid Greenman.Nd connect time accounting
39dea673e9SRodney W. Grimes.Sh SYNOPSIS
40dea673e9SRodney W. Grimes.Nm ac
41ff9c3a32SDavid Greenman.Op Fl dp
42ff9c3a32SDavid Greenman.\".Op Fl c Ar console
43ff9c3a32SDavid Greenman.Op Fl t Ar tty
44ff9c3a32SDavid Greenman.Op Fl w Ar wtmp
45dea673e9SRodney W. Grimes.Op Ar users ...
46dea673e9SRodney W. Grimes.Sh DESCRIPTION
47dea673e9SRodney W. GrimesIf the file
48dea673e9SRodney W. Grimes.Pa /var/log/wtmp
49ff9c3a32SDavid Greenmanexists, a record of individual login and logout
50ff9c3a32SDavid Greenmantimes are written to it by
51dea673e9SRodney W. Grimes.Xr login 8
52ff9c3a32SDavid Greenmanand
53ff9c3a32SDavid Greenman.Xr init 8 ,
54dea673e9SRodney W. Grimesrespectively.
55ff9c3a32SDavid Greenman.Nm \&Ac
562362d22eSJoerg Wunschexamines these records and writes the accumulated connect time (in hours)
57ff9c3a32SDavid Greenmanfor all logins to the standard output.
58dea673e9SRodney W. Grimes.Pp
59ff9c3a32SDavid GreenmanThe options are as follows:
60ff9c3a32SDavid Greenman.Bl -tag -width indentXXX
61dea673e9SRodney W. Grimes.It Fl d
62dea673e9SRodney W. GrimesDisplay the connect times in 24 hour chunks.
63ff9c3a32SDavid Greenman.\" .It Fl c Ar console
64ff9c3a32SDavid Greenman.\" Use
65ff9c3a32SDavid Greenman.\" .Ar console
66ff9c3a32SDavid Greenman.\" as the name of the device that local X sessions (ut_host of ":0.0")
67ff9c3a32SDavid Greenman.\" originate from.  If any login has been recorded on
68ff9c3a32SDavid Greenman.\" .Ar console
69ff9c3a32SDavid Greenman.\" then these X sessions are ignored unless COMPAT_SUNOS was defined at
70ff9c3a32SDavid Greenman.\" compile time.
71dea673e9SRodney W. Grimes.It Fl p
72ff9c3a32SDavid GreenmanPrint individual users' totals.
73ff9c3a32SDavid Greenman.It Fl t Ar tty
74ff9c3a32SDavid GreenmanOnly do accounting logins on certain ttys.  The
75ff9c3a32SDavid Greenman.Ar tty
76ff9c3a32SDavid Greenmanspecification can start with '!' to indicate not this
77ff9c3a32SDavid Greenman.Ar tty
78ff9c3a32SDavid Greenmanand end with '*' to indicate all similarly named ttys.
79ff9c3a32SDavid GreenmanMultiple
80ff9c3a32SDavid Greenman.Fl t
81ff9c3a32SDavid Greenmanflags may be specified.
82ff9c3a32SDavid Greenman.It Fl w Ar wtmp
83ff9c3a32SDavid GreenmanRead connect time data from
84ff9c3a32SDavid Greenman.Ar wtmp
85ff9c3a32SDavid Greenmaninstead of the default file,
86dea673e9SRodney W. Grimes.Pa /var/log/wtmp .
87dea673e9SRodney W. Grimes.It Ar users ...
88ff9c3a32SDavid GreenmanDisplay totals for the given individuals only.
89dea673e9SRodney W. Grimes.El
90dea673e9SRodney W. Grimes.Pp
91dea673e9SRodney W. GrimesIf no arguments are given,
92ff9c3a32SDavid Greenman.Nm ac
93ff9c3a32SDavid Greenmandisplays the total connect time for all
94ff9c3a32SDavid Greenmanaccounts with login sessions recorded in
95ff9c3a32SDavid Greenman.Pa wtmp .
96dea673e9SRodney W. Grimes.Pp
97dea673e9SRodney W. GrimesThe default
98dea673e9SRodney W. Grimes.Pa wtmp
99ff9c3a32SDavid Greenmanfile will increase without bound unless it is truncated.
100ff9c3a32SDavid GreenmanIt is normally truncated by the daily scripts run
101ff9c3a32SDavid Greenmanby
102ff9c3a32SDavid Greenman.Xr cron 8 ,
103dea673e9SRodney W. Grimeswhich rename and rotate the
104dea673e9SRodney W. Grimes.Pa wtmp
105ff9c3a32SDavid Greenmanfiles, keeping a week's worth of data on
106ff9c3a32SDavid Greenmanhand.  No login or connect time accounting is performed if
107ff9c3a32SDavid Greenman.Pa /var/log/wtmp
108ff9c3a32SDavid Greenmandoes not exist.
109ff9c3a32SDavid Greenman.Pp
110ff9c3a32SDavid GreenmanFor example,
111ff9c3a32SDavid Greenman.Bd -literal -offset
112ff9c3a32SDavid Greenmanac -p -t "ttyd*" > modems
113ff9c3a32SDavid Greenmanac -p -t "!ttyd*" > other
114ff9c3a32SDavid Greenman.Ed
115ff9c3a32SDavid Greenman.Pp
116ff9c3a32SDavid Greenmanallows times recorded in
117ff9c3a32SDavid Greenman.Pa modems
118ff9c3a32SDavid Greenmanto be charged out at a different rate than
119ff9c3a32SDavid Greenman.Pa other .
120ff9c3a32SDavid Greenman.Pp
121ff9c3a32SDavid GreenmanThe
122ff9c3a32SDavid Greenman.Nm ac
123ff9c3a32SDavid Greenmanutility exits 0 on success, and >0 if a fatal error occurs.
124dea673e9SRodney W. Grimes.Sh FILES
125dea673e9SRodney W. Grimes.Bl -tag -width /var/log/wtmp.[0-7] -compact
126dea673e9SRodney W. Grimes.It Pa /var/log/wtmp
127ff9c3a32SDavid Greenmanconnect time accounting file
128dea673e9SRodney W. Grimes.It Pa /var/log/wtmp.[0-7]
129dea673e9SRodney W. Grimesrotated files
130dea673e9SRodney W. Grimes.El
131dea673e9SRodney W. Grimes.Sh SEE ALSO
132dea673e9SRodney W. Grimes.Xr init 8 ,
133dea673e9SRodney W. Grimes.Xr sa 8 ,
134dea673e9SRodney W. Grimes.Xr login 1 ,
135ff9c3a32SDavid Greenman.Xr utmp
136ff9c3a32SDavid Greenman.\" .Sh NOTES
137ff9c3a32SDavid Greenman.\" If COMPAT_SUNOS is defined
138ff9c3a32SDavid Greenman.\" .Nm ac
139ff9c3a32SDavid Greenman.\" ignores the fact that entries with ut_host of ":0.0" are not real
140ff9c3a32SDavid Greenman.\" login sessions.  Normally such entries are ignored except in the case
141ff9c3a32SDavid Greenman.\" of a user being logged in when the
142ff9c3a32SDavid Greenman.\" .Pa wtmp
143ff9c3a32SDavid Greenman.\" file was rotated, in which case a login with ut_host of ":0.0" may
144ff9c3a32SDavid Greenman.\" appear without any preceeding console logins.
145ff9c3a32SDavid Greenman.\" If no one is logged in on the console, the user is deemed to have
146ff9c3a32SDavid Greenman.\" logged in on at the earliest time stamp found in
147ff9c3a32SDavid Greenman.\" .Pa wtmp .
148ff9c3a32SDavid Greenman.\" Use of
149ff9c3a32SDavid Greenman.\" .Pa console
150ff9c3a32SDavid Greenman.\" allows
151ff9c3a32SDavid Greenman.\" .Nm ac
152ff9c3a32SDavid Greenman.\" to identify and correcty process a logout for the user.  The default
153ff9c3a32SDavid Greenman.\" value for
154ff9c3a32SDavid Greenman.\" .Pa console
155ff9c3a32SDavid Greenman.\" is usually correct at compile time.
156