您现在的位置是:首页 > 文章详情

熟悉CentOS系统日志,screen工具

日期:2017-12-06点击:391

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

原文链接:https://www.centoschina.cn/command/help/9392.html
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章