ac 中文man頁(yè)面
名字
ac - 輸出用戶(hù)連接時(shí)間
總覽
- 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 基于當(dāng)前的 /var/log/wtmp 文件中的登錄和退出時(shí)間輸出一個(gè)關(guān)于連接時(shí)間(以小時(shí)為單位)的報(bào)告。并且還輸出一個(gè)總計(jì)時(shí)間。
記帳文件 /var/log/wtmp 由 init(8) 和 login(1) 維護(hù)。ac 和 login 均不生成 /var/log/wtmp 文件,如果記帳文件不存在,則不做記帳工作。如果要開(kāi)始記帳,應(yīng)生成一個(gè)長(zhǎng)度為零的記帳文件。
注意:文件 /var/log/wtmp 可能很快就變得非常大。你可能隔一段時(shí)間就要裁減一下這個(gè)文件。
GNU ac 工作起來(lái)與 u*x ac 基本一樣,但也在幾個(gè)方面有小的改進(jìn)。你可能希望看到 GNU ac 和其他系統(tǒng)上的 ac 在輸出上的不同。想得到額外的信息,請(qǐng)使用命令 info accounting。
選項(xiàng)
..PD 0
- -d, --daily-totals
- 為每天輸出輸出一個(gè)總計(jì)時(shí)間,而不是在結(jié)尾輸出一大的總計(jì)。輸出可能象下面這樣:
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
- 為每個(gè)用戶(hù)輸出總計(jì)時(shí)間,并在最后追加一個(gè)所有用戶(hù)的總計(jì)時(shí)間的累計(jì)值。輸出可能象下面這樣:
bob 8.06
goff 0.60
maley 7.37
root 0.12
total 16.15 - [用戶(hù)列表]
- 輸出的是在用戶(hù)列表中包括的所有用戶(hù)的連接時(shí)間的總計(jì)和值。用戶(hù)列表由空格分隔,其中不允許有通配符。
- -f, --file filename
- 從指定文件而不是系統(tǒng)的 /var/log/wtmp 文件中讀取記帳信息。
- --complain
- 當(dāng) /var/log/wtmp 存在著問(wèn)題(時(shí)間扭曲,丟失記錄,或其他任何問(wèn)題),輸出一個(gè)適當(dāng)?shù)腻e(cuò)誤信息。
- --reboots
- 重新引導(dǎo)(reboot)記錄不是在系統(tǒng)重新引導(dǎo)時(shí)寫(xiě)的,而是在系統(tǒng)重新啟動(dòng)(restart)時(shí)寫(xiě)的。所以不可能知道重新引導(dǎo)的精確的發(fā)生時(shí)間。用戶(hù)在系統(tǒng)重新引導(dǎo)時(shí)可能已經(jīng)在系統(tǒng)上登錄了,許多 ac 依據(jù)用戶(hù)(的要求)自動(dòng)的統(tǒng)計(jì)在登錄與重新引導(dǎo)記錄之間的時(shí)間(盡管所有的這些時(shí)間不應(yīng)是問(wèn)題,但系統(tǒng)關(guān)機(jī)很長(zhǎng)的時(shí)間時(shí)可能就是了)。如果你打算統(tǒng)計(jì)這個(gè)時(shí)間,就應(yīng)包括此選項(xiàng)。
*要求對(duì) vanilla ac 的兼容性,就要包含此選項(xiàng)* - --supplants
- 有時(shí),注銷(xiāo)記錄沒(méi)有寫(xiě)出明確的終端,因而最近的用戶(hù)的自然增長(zhǎng)的時(shí)間就不能被計(jì)算。如果你打算包括在一個(gè)終端上的從用戶(hù)登錄到下一次登錄的時(shí)間(盡管可能是不正確的),就應(yīng)包括此選項(xiàng)。
*要求對(duì) vanilla ac 的兼容性,就要包含此選項(xiàng)* - --timewarps
- 一些時(shí)候,在 @WTMP_FILE_LOC 文件中的記錄可能突然跳回到了以前的時(shí)間而卻沒(méi)有時(shí)鐘更改記錄出現(xiàn)。在這種情況發(fā)生時(shí),不可能知道用戶(hù)登錄了多長(zhǎng)時(shí)間。如果你打算依據(jù)用戶(hù)(的要求)統(tǒng)計(jì)從登錄到時(shí)間扭曲之間的時(shí)間,就應(yīng)包括此選項(xiàng)。 *要求對(duì) vanilla ac 的兼容性,就要包含此選項(xiàng)*
- --compatibility
- 這是上面三種選項(xiàng)的速寫(xiě),就不用敲三次鍵盤(pán)了。
- -a, --all-days
- 如果我們?cè)谳敵鋈湛傆?jì)時(shí)使用了此參數(shù),則輸出每天的記錄,而不是忽略掉沒(méi)有登錄活動(dòng)的間隔日。沒(méi)有此選項(xiàng)時(shí),在這些間隔日期間自然增長(zhǎng)的時(shí)間被列在下一天即有登錄活動(dòng)的那一天的底下。
- --tw-leniency num
- 設(shè)置時(shí)間扭曲的寬限為 num 秒。在 /var/log/wtmp 文件中的記錄可能輕微的亂了次序(最顯著的是當(dāng)兩個(gè)登錄發(fā)生在
一前一后的時(shí)期,第二個(gè)可能先寫(xiě)了記錄)。缺省的值被設(shè)置為60。如果程序注意到了這個(gè)問(wèn)題,除非使用了--timewarps 選項(xiàng),否則不把時(shí)間賦給用戶(hù)。 - --tw-suspicious num
- 設(shè)置時(shí)間扭曲的不信任值為 num 秒。如果 /var/log/wtmp 文件中的兩個(gè)記錄超出了這個(gè)秒間隔數(shù),那么 在 @WTMP_FILE_LOC 文件中一定存在問(wèn)題(或者你的機(jī)器已經(jīng)一年沒(méi)有使用了)。如果程序注意到了這個(gè)問(wèn)題,除非使用了--timewarps選項(xiàng),否則不把時(shí)間賦給用戶(hù)。
- -y, --print-year
在顯示日期的時(shí)候輸出年份。- -z, --print-zeros
- 一個(gè)任何類(lèi)別的總計(jì)(除了全部總計(jì))是零,還是輸出此總計(jì)。缺省時(shí)禁止輸出是零的總計(jì)。
- --debug
- 輸出冗余的內(nèi)部(調(diào)試)信息。
- -V, --version
- 在標(biāo)準(zhǔn)輸出上輸出版本號(hào)并退出。
- -h, --help
- 在標(biāo)準(zhǔn)輸出上輸出使用方法并退出。
相關(guān)文件
.I /var/log/wtmp 系統(tǒng)范圍的登錄記錄文件。進(jìn)一步的細(xì)節(jié)參見(jiàn) wtmp(5)。
著作者
GNU 的記帳工具是由 Noel Cragg 寫(xiě)的。手冊(cè)頁(yè)是從 Susan Kleinmann 寫(xiě)的關(guān)于記帳的 texinfo 頁(yè)轉(zhuǎn)換而來(lái)的。
參見(jiàn)
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)