Linux系统日志

linux 系统日志

  • /var/log/messages
  • /etc/logrotate.conf 日志切割配置文件
  • http://www.javashuo.com/article/p-tauwscem-r.html logrotate 使用详解
  • dmesg 命令
  • /var/log/dmesg 日志
  • last命令,调用文件时/var/log/wtmp
  • blast命令查看登陆失败的用户,对应的文件/var/log/btmp
  • /var/log/secure

  • /var/log/messages ·····记录linux系统中总的日志python

  • /etc/logrotate.conf 日志切割配置文件linux

[root@xuexi-001 ~]# ls /var/log/messages*
/var/log/messages  /var/log/messages-20180611  /var/log/messages-20180617
[root@xuexi-001 ~]# cat /etc/logrotate.conf 
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
	minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.
  • dmesg 命令 ````列出系统硬件的的日志,保存在内存当中。安全

  • dmesg -c 清空日志工具

  • /var/log/dmesg 日志 系统启动记录的一些日志文件,与dmesg命令没有关系this

  • last命令,调用文件时/var/log/wtmp.net

  • blast命令查看登陆失败的用户,对应的文件/var/log/btmp日志

[root@xuexi-001 ~]# lastb
root     tty1                          Tue Jun  5 19:27 - 19:27  (00:00)    

btmp begins Tue Jun  5 19:27:48 2018
  • /var/log/secure ····· 记录安全的日志文件

screen 工具·····虚拟的一个终端

  • 为了避免让一个任务意外中断
  • nohup command &
  • screen是一个虚拟终端
  • yum install -y screen
  • screen直接回车就进入了虚拟终端
  • ctral a组合键再按d退出虚拟终端,但不是结束
  • screen -ls 查看虚拟终端列表
  • screen -r id 进入指定的终端
  • screen -S aming
  • screen -r aming

  • nohup command & 将任务丢到后台 nohup 命令 + 日志 + &
[root@xuexi-001 ~]# screen  //进入虚拟终端
[root@xuexi-001 ~]# vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 2  0      0 1434460   2076 303788    0    0    65    27   87   99  0  0 98  1  0
 0  0      0 1434460   2076 303788    0    0     0     0  106  106  0  0 100  0  0
 0  0      0 1434460   2076 303788    0    0     0     0   84   77  0  0 100  0  0
 0  0      0 1434460   2076 303788    0    0     0     0   89   83  0  0 100  0  0
 // ctral a组合键再按d退出虚拟终端,但不是结束
 [detached from 1627.pts-0.xuexi-001]
 [root@xuexi-001 ~]# screen -r 1627 //再次进入虚拟终端
 [root@xuexi-001 ~]# exit //退出虚拟终端
 [root@xuexi-001 ~]# screen -ls  // `列出运行的虚拟终端
No Sockets found in /var/run/screen/S-root.

自定义screen 的名称,以便于长时间运行忘记执行中的任务code

screen -S "test-screen"orm

[root@xuexi-001 ~]# screen -S "test-screen"
[root@xuexi-001 ~]# sleep 1000
[root@xuexi-001 ~]# screen -ls
There is a screen on:
	1687.test-screen	(Detached)
1 Socket in /var/run/screen/S-root.
[root@xuexi-001 ~]# screen -r test-screen
[detached from 1687.test-screen]
相关文章
相关标签/搜索