Linux 登录统计小工具——ac
Linux 登录统计小工具——ac
安装
redhat/centos/rocky
# yum provides ac psacct-6.6.1-13.el7.x86_64 : Utilities for monitoring process activities Repo : os Matched from: Filename : /usr/bin/ac # yum -y install psacct
Ubuntu/debian
$ sudo apt-get install acct 或 # apt-get install acctStarting psacct or acct service
默认情况下,psacct服务处于禁用模式,你需要在RHEL/CentOS/Fedora系统下手动开启该服务。请使用下列命令,检查服务状态。
# /etc/init.d/psacct status Process accounting is disabled. # chkconfig psacct on # /etc/init.d/psacct start Starting process accounting: [ OK ]
显示用户连接时间的统计信息
没有指定参数的ac命令会基于来自当前wtmp文件的用户登录/退出,显示连接时间(小时)的总统计信息。
# ac total 1141.26
显示每天的用户统计信息
使用ac -d这个命令将输出每天的总登录时间(小时)。
# ac -d Apr 1 total 2.90 Apr 2 total 17.00 Apr 3 total 4.55 Apr 6 total 1.04 Apr 8 total 1.69
显示每个用户的时间总数
使用ac -p这个命令将显示每个用户的总登录时间(小时)。
# ac -p root 1136.88 yunwei 4.40 total 1141.28
显示单个用户时间
想得到tecmint这个用户的总登录统计时间(小时),请使用下列命令。
# ac yunwei total 4.40
显示用户每天的登录时间
下列命令将输出tecmint这个用户的每天总登录时间(小时)。
# ac -d yunwei Aug 12 total 0.01 Aug 16 total 0.61 Aug 17 total 2.81 Aug 18 total 0.00
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2022-02-08 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.