/var/log/messages是系统总日志,包含系统,运行时的消息状态,网络错误都会记录到这个文件中。他会隔一段时间自动切割(logrotate)。
[root@shuai-01 ~]# ls /var/log/messages*
/var/log/messages /var/log/messages-20171128
/var/log/messages-20171113 /var/log/messages-20171203
/var/log/messages-20171120
logrotate自动切割日志,配置文件(/etc/logrotate.conf)
[root@shuai-01 ~]# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly //每周切割
# keep 4 weeks worth of backlogs
rotate 4 //保留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 作用:显示系统启动信息
查看登录系统的信息:
命令:last 调用日志文件:/var/log/wtmp 查看登录时的详细信息,登录日期,时长,终端,账户名
命令:lastb 调用日志文件:/var/log/btmp 显示账户登录失败的信息
screen工具
执行一个脚本,需要它连续不间断运行。加上&,将脚本放在后台运行,但是退出终端时,脚本也可能会退出。这时有两种方法,一种是nohup运行脚本,一种是screen工具。 1. 使用nohup 运行脚本时前面加上 nohup sh /usr/local/sbin/sleep.sh & 2.screen工具 screen类似于一个虚拟终端。 安装screen命令:
[root@shuai-01 ~]# yum install -y screen
直接运行screen进入虚拟终端
运行脚本,
退出screen(Ctrl+a ,在按d)
在虚拟终端下结束(exit)
查看以打开的screen会话:screen -ls
打开某个screen会话:screen -r ID
给虚拟终端创建时起个名字:screen -S “test_screen”
本文由 CentOS中文站 - 专注Linux技术 作者:centos 发表,其版权均为 CentOS中文站 - 专注Linux技术 所有,文章内容系作者个人观点,不代表 CentOS中文站 - 专注Linux技术 对观点赞同或支持。如需转载,请注明文章来源。