ac
Report user connection time (login duration)
TLDR
Print how long the current user has been connected in hours
Print how long users have been connected in hours
Print how long a particular user has been connected in hours
Print how long a particular user has been connected in hours per [d]ay (with total)
SYNOPSIS
ac [OPTIONS]
PARAMETERS
-p, --individual-totals
Displays connect time for each individual user.
-d, --daily-totals
Shows the total connect time for each day.
-y, --print-year
Used with --daily-totals to include the year in the daily output.
-f <file>, --file <file>
Reads connect time data from the specified wtmp file instead of the default /var/log/wtmp.
--reboots
Includes system reboots in the accounting.
--suppress-reboots
Excludes system reboots from the accounting.
--bad-dates
Prints all records with bad time stamps.
--debug
Prints verbose debugging information.
--version
Displays version information and exits.
--help
Displays a help message and exits.
DESCRIPTION
ac (access or accounting) is a utility that reports on system user connect times, calculated from login and logout entries in the /var/log/wtmp file.
By default, it outputs the total cumulative connect time for all users in hours. Users can specify options to view individual user totals, daily breakdowns, or process a different wtmp file. It's an essential tool for system administrators to monitor user activity and track resource usage over time. The output is typically in hours, providing a high-level overview of system access patterns.
CAVEATS
ac relies on wtmp file integrity; a corrupted file can lead to inaccurate reports.
wtmp can grow very large, affecting performance and disk space; it's often rotated by logrotate.
ac only counts login/logout events, not active usage within a session.
Accuracy depends on proper system clock and time synchronization.
LOG FILE LOCATION
The default wtmp file processed by ac is /var/log/wtmp. This file records all login, logout, and system reboot/shutdown events.
TIME UNIT
All connect times reported by ac are in hours. Fractional hours are displayed as decimal values (e.g., 1.5 for one hour and thirty minutes).
HISTORY
The ac command is part of the GNU Accounting Utilities, which have been a standard component of Unix-like operating systems for many years. Its purpose remains consistent: to provide a simple, cumulative report of user access times based on the wtmp log file. Its development has focused on maintaining compatibility with various system architectures and improving robustness in parsing potentially malformed log entries, rather than adding complex new features. It's a foundational utility for basic system usage monitoring.