linux系统日志,screen工具

/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”

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值