发布时间:2018-12-12 13:36:45编辑:丝画阁阅读(1152)
因为我是做运维工作的,主要负责Linux系统交付这块的工作,所以经常需要查看系统的安装完成时间,来分析工作中的一些问题。查看的方法就是执行last命令,根据系统最近一次的启动时间和次数来判断是什么时候重装完成的。在这里简单的写写last命令的用法,命令其实很简单,只不过经常用,应该多了解一点
[root@py-test ~]# >/var/log/wtmp [root@py-test ~]# last wtmp begins Thu Feb 8 20:06:54 2018
[root@centostest ~]# last |tail -n 10 root tty1 Tue Sep 6 03:56 - down (00:00)
root pts/0 192.168.141.65 Tue Sep 6 03:53 - down (00:03)
reboot system boot 2.6.32-431.el6.x Tue Sep 6 03:52 - 03:56 (00:03)
root pts/0 192.168.141.65 Tue Sep 6 03:51 - down (00:00)
reboot system boot 2.6.32-431.el6.x Tue Sep 6 03:50 - 03:52 (00:01)
root pts/0 192.168.154.78 Thu Apr 7 01:53 - down (00:02)
root tty1 Thu Apr 7 01:48 - down (00:07)
reboot system boot 2.6.32-431.el6.x Thu Apr 7 01:47 - 01:55 (00:07)
wtmp begins Thu Apr 7 01:47:55 2016
[root@centostest ~]# last -x shutdown shutdown system down 2.6.32-431.el6.x Tue Sep 6 03:56 - 19:09 (420+15:13) shutdown system down 2.6.32-431.el6.x Tue Sep 6 03:52 - 03:52 (00:00) shutdown system down 2.6.32-431.el6.x Thu Apr 7 01:55 - 03:50 (152+01:54) wtmp begins Thu Apr 7 01:47:55 2016
[root@centostest ~]# last -x reboot reboot system boot 2.6.32-431.el6.x Tue Oct 31 19:09 - 03:42 (100+08:32) reboot system boot 2.6.32-431.el6.x Tue Sep 6 03:52 - 03:56 (00:03) reboot system boot 2.6.32-431.el6.x Tue Sep 6 03:50 - 03:52 (00:01) reboot system boot 2.6.32-431.el6.x Thu Apr 7 01:47 - 01:55 (00:07) wtmp begins Thu Apr 7 01:47:55 2016
这个不多解释了
[root@centostest ~]# uptime 03:44:42 up 100 days, 8:35, 2 users, load average: 0.00, 0.00, 0.00
这里需要启动psacct 服务器,才能有显示
[root@centostest ~]# service psacct start Starting process accounting: [ OK ]
[root@centostest ~]# lastcomm root service root pts/0 0.00 secs Fri Feb 9 03:45 psacct root pts/0 0.00 secs Fri Feb 9 03:45 touch root pts/0 0.00 secs Fri Feb 9 03:45 accton S root pts/0 0.00 secs Fri Feb 9 03:45
关键字:
本站部分内容来源网络及网友上传,本站未必能一一鉴别其是否为公共版权或其版权归属,如果您认为侵犯您的权利,本站将表示非常抱歉!
请您速联系本站,本站一经核实,立即删除。删文删帖联系【2789291421@qq.com】