AC(8)

NAME
ac - connect time accounting

SYNOPSIS
ac [-dp] [-t tty] [-w wtmp] [users ...]

DESCRIPTION
If the file /var/log/wtmp exists, a record of individual login and logout times are written to it by login(1) and init(8), respectively. ac> examines these records and writes the accumulated connect time (in hours) for all logins to the standard output.

The options are as follows:

-d  Display the connect times in 24 hour chunks.

-p  Print individual users' totals.

-t tty
    Only do accounting logins on certain ttys. The tty specification can start with '!' to indicate not this tty and end with '*' to indicate all similarly named ttys. Multiple -t flags may be specified.

-w wtmp
    Read connect time data from wtmp instead of the default file, /var/log/wtmp.

users ...
    Display totals for the given individuals only.

If no arguments are given, ac displays the total connect time for all accounts with login sessions recorded in wtmp.

The default wtmp file will increase without bound unless it is truncated. It is normally truncated by the daily scripts run by cron(8), which rename and rotate the wtmp files, keeping a week's worth of data on hand. No login or connect time accounting is performed if /var/log/wtmp does not exist.

For example,

    ac -p -t "ttyd*" > modems
    ac -p -t "!ttyd*" > other

allows times recorded in modems to be charged out at a different rate than other.

The ac utility exits 0 on success, and >0 if a fatal error occurs.

FILES
/var/log/wtmp
    connect time accounting file
/var/log/wtmp.[0-7]
    rotated files

SEE ALSO
login(1), utmp(5), init(8), sa(8)