学习Linux系统日志管理
学习Linux系统日志管理
1. 连接时间的日志
连接时间日志一般由/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)
[root@xhot ~]# w
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
[root@xhot ~]# ac -p //查看每个用户的连接时间
u51 1.23
u55 0.04
root 95.21 //可以看到root连接时间最长吧
xhot 0.06
user1 3.93
total 100.48
[root@xhot ~]# ac -a //查看所有用户的连接时间
total 100.49
[root@xhot ~]# ac -d //查看用户每天的连接时间
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
2. 进程监控日志
进程统计监控日志在监控用户的操作指令是非常有效的。当服务器最近发现经常无故关机或者无故被人删除文件等现象时,可以通过使用进程统计日志查看:
[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 //关闭进程统计日志监控
3. 系统和服务日志
系统日志服务是由一个名为syslog的服务管理的,如一下日志文件都是由syslog日志服务驱动的:
/var/log/lastlog :记录最后一次用户成功登陆的时间、登陆IP等信息
/var/log/messages :记录Linux操作系统常见的系统和服务错误信息
/var/log/secure :Linux系统安全日志,记录用户和工作组变坏情况、用户登陆认证情况
/var/log/btmp :记录Linux登陆失败的用户、时间以及远程IP地址
/var/log/cron :记录crond计划任务服务执行情况
…
[root@xhot ~]# cat /var/log/lastlog
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
…
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://www.juheyunku.com/jiaob/shell/10714.shtml
相关文章
热门TAG
命令 权重 外链 企业网站 白帽 php 织梦教程 dedecms修改内容 javascript 织梦 功能 标签 调用 详解 服务器 网站流量 实例解析 Dedecms 织梦cms HTML tags标签 python jquery教程 jquery windows SEO优化 蜘蛛 搜索引擎 网站收录 JSP最新文章
-
Centos下PHP5升级为PHP7的方法
时间:2021-01-03
-
在php当中常量和变量的区
时间:2020-12-29
-
PHP中经典的四大排序算法
时间:2020-12-29
-
dw怎么运行php文件?
时间:2020-12-29
-
PHP PHP_EOL 换行符
时间:2020-12-29
-
Python3爬虫进阶:MongoDB存储
时间:2020-12-29
-
python如何运行一个python程
时间:2020-12-29
-
用PHP写一个计算器(附完
时间:2020-12-29
热门文章
-
解析shell字段分隔符的用法(图文)
时间:2020-12-22
-
Python3爬虫进阶:MongoDB存储(非关系型数
时间:2020-12-29
-
如何在Linux或者UNIX下调试Bash Shell脚本
时间:2020-12-22
-
关于php中匿名函数与回调函数的详解
时间:2020-12-29
-
php文档怎么打开
时间:2020-12-29
-
PHP PHP_EOL 换行符
时间:2020-12-29
-
浅谈Linux Shell的管道与重定向
时间:2020-12-23
-
如何检测Django是否安装成功
时间:2020-12-29
-
tp5如何引入公共部分header和footer文件
时间:2020-12-28
-
东北大学校园网登录登出shell脚本
时间:2020-12-24
