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