Friday, April 03, 2009

透過ac command 顯示所有使用者登入的時間

今天看書,學習到利用ac指令來獲取系統上所有使用者上線的總時間,帽客覺得這是非常實用的指令,故於此分享給大家,以下是ac的簡單說明: (man page 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.

ok, 再來以上線跑不久的OpenSUSE11.1來做個例子:

Example1: 顯示每天所有使用者上線的時間總和:
linux-xgby:~ # ac -d
Mar 7 total 28.81
Mar 9 total 0.14
Mar 13 total 17.35
Mar 15 total 32.28
Mar 20 total 8.09
Mar 21 total 3.00
Mar 22 total 44.08
Mar 23 total 10.44
Mar 24 total 33.19
Mar 25 total 29.43
Mar 31 total 0.03
Apr 1 total 15.17
Apr 2 total 4.47
Apr 2 total 14.60
Apr 3 total 21.09
Today total 1.67

Example2: 顯示個別使用者上線的時間總和:
linux-xgby:~ # ac -p
lawrence 258.67
root 5.31
total 263.98

如何,夠簡單又實用吧!

No comments: