Linux ac --在线时间统计

来源:互联网 发布:odbc读取数据 编辑:程序博客网 时间:2024/05/16 01:49

用途说明

打印用户连接的时间 Printsstatistics about users' connect time.

ac命令根据当前的/var/log/wtmp文件中的登录进入和退出来报告用户连接的时间(小时),如果不使用标志,则报告总的时间【2】。也就是统计用户的在线时间。

常用参数

-d 按每天的统计数据打印。 Printtotals for each day rather than just one big total at the end.

-y 在显示日期的时候输出年份。Print year when displaying dates.

-p 打印每个账号的总的连接时间。Print time totals for each user in addition to the usualeverything-lumped-into-one value.

使用示例

示例一

[root@web ~]# ac

       total     1366.71

[root@web ~]# ac -d -y

Jun 282010     total       5.48

Jun 292010     total       15.97

Jun 302010     total       25.38

Jul  12010     total       33.62

Jul  32010     total       14.17

Jul  42010     total       24.94

Jul  52010     total       4.35

Jul  62010     total       46.59

Jul  72010     total       67.27

Jul  82010     total       41.07

Jul  92010     total       81.77

Jul 102010     total       45.72

Jul 122010     total       35.99

Jul 132010     total       52.14

Jul 142010     total       50.01

Jul 152010     total       37.90

Jul 162010     total       39.18

Jul 172010     total       6.59

Jul 182010     total       8.08

Jul 192010     total       10.93

Jul 202010     total       5.56

Jul 212010     total       11.23

Jul 232010     total       1.49

Aug  12010     total       6.91

Aug  92010     total       9.36

Aug 102010     total       34.48

Aug 112010     total       24.88

Aug 122010     total       24.21

Aug 132010     total       38.00

Aug 142010     total       9.05

Aug 192010     total       26.42

Aug 202010     total       62.44

Aug 212010     total       9.58

Aug 232010     total       22.59

Aug 252010     total       0.17

Aug 272010     total       4.56

Aug 302010     total       1.03

Aug 312010     total       9.67

Sep  12010     total       1.51

Sep  22010     total       4.82

Sep  52010     total       3.71

Sep  62010     total       0.38

Sep  72010     total       44.68

Sep  82010     total       0.65

Sep  92010     total       31.65

Sep 102010     total       31.27

Sep 112010     total       0.41

Sep 122010     total       9.70

Sep 132010     total       14.57

Sep 142010     total       27.97

Sep 152010     total       13.19

Sep 162010     total       14.82

Sep 172010     total       14.37

Sep 182010     total       16.20

Sep 192010     total       30.74

Sep 202010     total       27.55

Sep 212010     total       27.44

Sep 242010     total       3.46

Sep 252010     total       21.43

Sep 262010     total       19.55

Sep 272010     total       14.24

Today          total       44.09

示例二

[root@web186 hycu2]#ac

       total       37.42

[root@web186 hycu2]#ac -d -y

Sep  12010     total       3.77

Sep  92010     total       6.70

Sep 132010     total       8.56

Sep 142010     total       4.75

Sep 152010     total       11.15

Sep 202010     total       2.19

Today          total        0.35

示例三

[web@hnweb1 ~]$ ac

       total      307.32

[web@hnweb1 ~]$ ac -d -y

Sep  22010     total       3.18

Sep  72010     total       3.19

Sep  82010     total       8.00

Sep  92010     total       3.03

Sep 132010     total       3.68

Sep 152010     total       4.16

Sep 172010     total       0.09

Sep 192010     total       0.07

Sep 202010     total       8.86

Sep 212010     total       25.89

Sep 252010     total      108.75

Sep 262010     total       50.91

Today          total       87.56

[web@hnweb1 ~]$ ac -d

Sep  2 total        3.18

Sep  7 total        3.19

Sep  8 total        8.00

Sep  9 total        3.03

Sep 13 total        3.68

Sep 15 total        4.16

Sep 17 total        0.09

Sep 19 total        0.07

Sep 20 total        8.86

Sep 21 total       25.89

Sep 25 total      108.75

Sep 26 total       50.91

Today  total       87.99

[web@hnweb1 ~]$ ac -p

       web                               211.76

       smp                                 0.09

       vas                                 1.98

       webipc                             93.99

       total      307.83

 

2010年10月8日晚上重新在这台上执行了上面的命令,结果如下:

[web@hnweb1 ~]$ ac -d -y

Today          total        3.14

[web@hnweb1 ~]$ ac -d

Today  total        3.15

[web@hnweb1 ~]$ ac -p

       web                                 0.01

       webipc                              3.14

       total        3.16

[web@hnweb1 ~]$

问题来了,只显示了本月(当天)的数据,上月的数据不见了!!!

问题思考

1. ac统计的时间是如何计算的?

2. ac-d显示的数据为什么不包括当天的数据?如上所示,今天是2010年9月28日,但打印出来的都没有包括今天的。

3. 怎么显示上月的数据?


0 0
原创粉丝点击