ac 中文man頁面
名字
ac - 輸出用戶連接時間
總覽
- ac
- [ -d | --daily-totals ] [ -y | --print-year ]
[ -p | --individual-totals ] [ people ]
[ -f | --file filename ] [ -a | --all-days ]
[ --complain ] [ --reboots ] [ --supplants ]
[ --timewarps ] [ --compatibility ]
[ --tw-leniency num ] [ --tw-suspicious num ]
[ -z | --print-zeros ] [ --debug ]
[ -V | --version ] [ -h | --help ]
描述
ac 基于當前的 /var/log/wtmp 文件中的登錄和退出時間輸出一個關于連接時間(以小時為單位)的報告。并且還輸出一個總計時間。
記帳文件 /var/log/wtmp 由 init(8) 和 login(1) 維護。ac 和 login 均不生成 /var/log/wtmp 文件,如果記帳文件不存在,則不做記帳工作。如果要開始記帳,應生成一個長度為零的記帳文件。
注意:文件 /var/log/wtmp 可能很快就變得非常大。你可能隔一段時間就要裁減一下這個文件。
GNU ac 工作起來與 u*x ac 基本一樣,但也在幾個方面有小的改進。你可能希望看到 GNU ac 和其他系統上的 ac 在輸出上的不同。想得到額外的信息,請使用命令 info accounting。
選項
..PD 0
- -d, --daily-totals
- 為每天輸出輸出一個總計時間,而不是在結尾輸出一大的總計。輸出可能象下面這樣:
Jul 3 total 1.17
Jul 4 total 2.10
Jul 5 total 8.23
Jul 6 total 2.10
Jul 7 total 0.30 - -p, --individual-totals
- 為每個用戶輸出總計時間,并在最后追加一個所有用戶的總計時間的累計值。輸出可能象下面這樣:
bob 8.06
goff 0.60
maley 7.37
root 0.12
total 16.15 - [用戶列表]
- 輸出的是在用戶列表中包括的所有用戶的連接時間的總計和值。用戶列表由空格分隔,其中不允許有通配符。
- -f, --file filename
- 從指定文件而不是系統的 /var/log/wtmp 文件中讀取記帳信息。
- --complain
- 當 /var/log/wtmp 存在著問題(時間扭曲,丟失記錄,或其他任何問題),輸出一個適當的錯誤信息。
- --reboots
- 重新引導(reboot)記錄不是在系統重新引導時寫的,而是在系統重新啟動(restart)時寫的。所以不可能知道重新引導的精確的發生時間。用戶在系統重新引導時可能已經在系統上登錄了,許多 ac 依據用戶(的要求)自動的統計在登錄與重新引導記錄之間的時間(盡管所有的這些時間不應是問題,但系統關機很長的時間時可能就是了)。如果你打算統計這個時間,就應包括此選項。
*要求對 vanilla ac 的兼容性,就要包含此選項* - --supplants
- 有時,注銷記錄沒有寫出明確的終端,因而最近的用戶的自然增長的時間就不能被計算。如果你打算包括在一個終端上的從用戶登錄到下一次登錄的時間(盡管可能是不正確的),就應包括此選項。
*要求對 vanilla ac 的兼容性,就要包含此選項* - --timewarps
- 一些時候,在 @WTMP_FILE_LOC 文件中的記錄可能突然跳回到了以前的時間而卻沒有時鐘更改記錄出現。在這種情況發生時,不可能知道用戶登錄了多長時間。如果你打算依據用戶(的要求)統計從登錄到時間扭曲之間的時間,就應包括此選項。 *要求對 vanilla ac 的兼容性,就要包含此選項*
- --compatibility
- 這是上面三種選項的速寫,就不用敲三次鍵盤了。
- -a, --all-days
- 如果我們在輸出日總計時使用了此參數,則輸出每天的記錄,而不是忽略掉沒有登錄活動的間隔日。沒有此選項時,在這些間隔日期間自然增長的時間被列在下一天即有登錄活動的那一天的底下。
- --tw-leniency num
- 設置時間扭曲的寬限為 num 秒。在 /var/log/wtmp 文件中的記錄可能輕微的亂了次序(最顯著的是當兩個登錄發生在
一前一后的時期,第二個可能先寫了記錄)。缺省的值被設置為60。如果程序注意到了這個問題,除非使用了--timewarps 選項,否則不把時間賦給用戶。 - --tw-suspicious num
- 設置時間扭曲的不信任值為 num 秒。如果 /var/log/wtmp 文件中的兩個記錄超出了這個秒間隔數,那么 在 @WTMP_FILE_LOC 文件中一定存在問題(或者你的機器已經一年沒有使用了)。如果程序注意到了這個問題,除非使用了--timewarps選項,否則不把時間賦給用戶。
- -y, --print-year
在顯示日期的時候輸出年份。- -z, --print-zeros
- 一個任何類別的總計(除了全部總計)是零,還是輸出此總計。缺省時禁止輸出是零的總計。
- --debug
- 輸出冗余的內部(調試)信息。
- -V, --version
- 在標準輸出上輸出版本號并退出。
- -h, --help
- 在標準輸出上輸出使用方法并退出。
相關文件
.I /var/log/wtmp 系統范圍的登錄記錄文件。進一步的細節參見 wtmp(5)。
著作者
GNU 的記帳工具是由 Noel Cragg 寫的。手冊頁是從 Susan Kleinmann 寫的關于記帳的 texinfo 頁轉換而來的。
參見
login(1), wtmp(5), init(8), sa(8)
#p#
NAME
ac - print statistics about users' connect time
SYNOPSIS
- ac
- [ -d | --daily-totals ] [ -y | --print-year ]
[ -p | --individual-totals ] [ people ]
[ -f | --file filename ] [ -a | --all-days ]
[ --complain ] [ --reboots ] [ --supplants ]
[ --timewarps ] [ --compatibility ]
[ --tw-leniency num ] [ --tw-suspicious num ]
[ -z | --print-zeros ] [ --debug ]
[ -V | --version ] [ -h | --help ]
DESCRIPTION
ac prints out a report of connect time (in hours) based on the logins/logouts in the current wtmp file. A total is also printed out.
The accounting file wtmp is maintained by init(8) and login(1). Neither ac nor login creates the wtmp if it doesn't exist, no accounting is done. To begin accounting, create the file with a length of zero.
NOTE: The wtmp file can get really big, really fast. You might want to trim it every once and a while.
GNU ac works nearly the same u*x ac, though it's a little smarter in several ways. You should therefore expect differences in the output of GNU ac and the output of ac's on other systems. Use the command info accounting to get additional information.
OPTIONS
..PD 0
- -d, --daily-totals
- Print totals for each day rather than just one big total at the end. The output looks like this:
Jul 3 total 1.17
Jul 4 total 2.10
Jul 5 total 8.23
Jul 6 total 2.10
Jul 7 total 0.30 - -p, --individual-totals
- Print time totals for each user in addition to the usual everything-lumped-into-one value. It looks like:
bob 8.06
goff 0.60
maley 7.37
root 0.12
total 16.15 - people
- Print out the sum total of the connect time used by all of the users included in people. Note that people is a space separated list of valid user names; wildcards are not allowed.
- -f, --file filename
- Read from the file filename instead of the system's wtmp file.
- --complain
- When the wtmp file has a problem (a time-warp, missing record, or whatever), print out an appropriate error.
- --reboots
- Reboot records are NOT written at the time of a reboot, but when the system restarts; therefore, it is impossible to know exactly when the reboot occurred. Users may have been logged into the system at the time of the reboot, and many ac'sautomatically count the time between the login and the reboot record against the user (even though all of that time shouldn't be, perhaps, if the system is down for a long time, for instance). If you want to count this time, include the flag. *For vanilla ac compatibility, include this flag.*
- --supplants
- Sometimes, a logout record is not written for a specific terminal, so the time that the last user accrued cannot be calculated. If you want to include the time from the user's login to the next login on the terminal (though probably incorrect), include this you want to include the time from the user's login to the next login on the terminal (though probably incorrect), include this flag. *For vanilla ac compatibility, include this flag.*
- --timewarps
- Sometimes, entries in a wtmp file will suddenly jump back into the past without a clock change record occurring. It is impossible to know how long a user was logged in when this occurs. If you want to count the time between the login and the time warp against the user, include this flag. *For vanilla ac compatibility, include this flag.*
- --compatibility
- This is shorthand for typing out the three above options.
- -a, --all-days
- If we're printing daily totals, print a record for every day instead of skipping intervening days where there is no login activity. Without this flag, time accrued during those intervening days gets listed under the next day where there is login activity.
- --tw-leniency num
- Set the time warp leniency to num seconds. Records in wtmp files might be slightly out of order (most notably when two logins occur within a one-second period - the second one gets written first). By default, this value is set to 60. If the program notices this problem, time is not assigned to users unless the --timewarps flag is used.
- --tw-suspicious num
- Set the time warp suspicious value to num seconds. If two records in the wtmp file are farther than this number of seconds apart, there is a problem with the wtmp file (or your machine hasn't been used in a year). If the program notices this problem, time is not assigned to users unless the --timewarps flag is used.
- -y, --print-year
- Print year when displaying dates.
- -z, --print-zeros
- If a total for any category (save the grand total) is zero, print it. The default is to suppress printing.
- --debug
- Print verbose internal information.
- -V, --version
- Print the version number of ac to standard output and quit.
- -h, --help
- Prints the usage string and default locations of system files to standard output and exits.
FILES
wtmp
- The system wide login record file. See wtmp(5) for further details.
AUTHOR
The GNU accounting utilities were written by Noel Cragg <noel@gnu.ai.mit.edu>. The man page was adapted from the accounting texinfo page by Susan Kleinmann <sgk@sgk.tiac.net>.
SEE ALSO
login(1), wtmp(5), init(8), sa(8)