学习Linux系统日志管理
连接时间日志一般由/var/log/wtmp和/var/run/utmp这两个文件记录,不过这两个文件无法直接cat查看,并且该文件由系统自动更新,可以通过如下:
w/who/finger/id/last/lastlog/ac 进行查看
[root@xhot ~]# who
root tty1 2010-10-06 22:56
root pts/0 2010-10-06 22:26 (218.192.87.4)
root pts/1 2010-10-06 23:41 (218.192.87.4)
root pts/3 2010-10-06 23:18 (218.192.87.4)
01:01:02 up 2:36, 4 users, load average: 0.15, 0.03, 0.01
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - 22:56 1:20m 0.16s 0.16s -bash
root pts/0 218.192.87.4 22:26 2:05m 0.18s 0.18s -bash
root pts/1 218.192.87.4 23:41 0.00s 0.41s 0.00s w
root pts/3 218.192.87.4 23:18 1:38m 0.03s 0.03s -bash
u51 1.23
u55 0.04
root 95.21 //可以看到root连接时间最长吧
xhot 0.06
user1 3.93
total 100.48
total 100.49
Sep 24 total 0.14
Sep 25 total 14.60
Sep 26 total 13.71
Sep 27 total 21.47
Sep 28 total 11.74
Sep 29 total 6.60
Sep 30 total 8.81
Oct 1 total 9.04
Oct 2 total 0.47 //可以看到我国庆3、4、5号出去玩了
Oct 6 total 8.62
Today total 5.29
[root@xhot ~]# accton /var/account/pacct //开启进程统计日志监控
[root@xhot ~]# lastcomm //查看进程统计日志情况
accton S root pts/1 0.00 secs Thu Oct 7 01:20
accton root pts/1 0.00 secs Thu Oct 7 01:20
ac root pts/1 0.00 secs Thu Oct 7 01:14
ac root pts/1 0.00 secs Thu Oct 7 01:14
free root pts/1 0.00 secs Thu Oct 7 01:10
lastcomm root pts/1 0.00 secs Thu Oct 7 01:09
bash F root pts/1 0.00 secs Thu Oct 7 01:09
lastcomm root pts/1 0.00 secs Thu Oct 7 01:09
ifconfig root pts/1 0.00 secs Thu Oct 7 01:09
lastcomm root pts/1 0.00 secs Thu Oct 7 01:09
lastcomm root pts/1 0.00 secs Thu Oct 7 01:09
lastcomm root pts/1 0.00 secs Thu Oct 7 01:09
accton S root pts/1 0.00 secs Thu Oct 7 01:09
[root@xhot ~]# accton //关闭进程统计日志监控
系统日志服务是由一个名为syslog的服务管理的,如一下日志文件都是由syslog日志服务驱动的:
/var/log/lastlog :记录最后一次用户成功登陆的时间、登陆IP等信息
/var/log/messages :记录Linux操作系统常见的系统和服务错误信息
/var/log/secure :Linux系统安全日志,记录用户和工作组变坏情况、用户登陆认证情况
/var/log/btmp :记录Linux登陆失败的用户、时间以及远程IP地址
/var/log/cron :记录crond计划任务服务执行情况
…
Lpts/0218.192.87.4
Lpts/1218.192.87.4
Lpts/1218.192.87.4
Lpts/0218.192.87.46
Lpts/0218.192.87.4
…
您可能感兴趣的文章:
学习Linux系统日志管理
Linux根据系统日志查看网卡是否报错
Linux管理日志系统详解
Linux日志服务介绍和日志服务器配置
使用日志保护Linux的安全
Linux下自动清理日志的shell脚本
php系统日志切割的实例
PHP错误日志的使用及汇总
查看linux日志的方法
用ASP.NET将网页错误信息写入系统日志