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]
相關文章
相關標籤/搜索