We know that we can use uptime command to know the uptime of linux server.
By using uptime command we can know only uptime of server,it does not displays when the server rebooted or shutdown.
[root@gw-server ~]# uptime
08:19:52 up 100 days, 23:19, 1 user, load average: 0.05, 0.14, 0.13
[root@gw-server ~]#
Command Shows list of Date and Time of server when server has rebooted/shutdown
[root@gw-server ~]# date
Sun Nov 12 08:19:36 EST 2017
[root@gw-server ~]# last -x | grep reboot
reboot system boot 3.10.0-514.26.2. Thu Aug 3 09:59 - 08:19 (100+23:19)
reboot system boot 3.10.0-514.26.2. Thu Aug 3 09:52 - 09:59 (00:07)
reboot system boot 3.10.0-229.el7.x Thu Aug 3 09:35 - 09:52 (00:16)
reboot system boot 3.10.0-229.el7.x Fri Mar 3 16:13 - 09:35 (152+16:21)
reboot system boot 3.10.0-229.el7.x Thu May 12 08:24 - 16:12 (295+08:48)
reboot system boot 3.10.0-229.el7.x Mon Nov 2 05:53 - 08:23 (192+01:30)
reboot system boot 3.10.0-229.el7.x Thu Oct 1 05:29 - 05:53 (32+01:23)
reboot system boot 3.10.0-229.4.2.e Tue Sep 29 08:49 - 05:29 (1+20:39)
reboot system boot 3.10.0-229.el7.x Tue Sep 29 08:25 - 08:49 (00:23)
reboot system boot 3.10.0-229.el7.x Tue Sep 29 08:25 - 08:25 (00:00)
[root@gw-server ~]#
If you observe below line 100+23:19 means 100 days+23 hours and 19 minutes.
reboot system boot 3.10.0-514.26.2. Thu Aug 3 09:59 - 08:19 (100+23:19)
[root@gw-server ~]# last -x | grep shutdown
shutdown system down 3.10.0-514.26.2. Thu Aug 3 09:59 - 09:59 (00:00)
shutdown system down 3.10.0-229.el7.x Thu Aug 3 09:52 - 09:52 (00:00)
shutdown system down 3.10.0-229.el7.x Thu Aug 3 09:35 - 09:35 (00:00)
shutdown system down 3.10.0-229.el7.x Fri Mar 3 16:12 - 16:13 (00:00)
shutdown system down 3.10.0-229.el7.x Thu May 12 08:23 - 08:24 (00:01)
shutdown system down 3.10.0-229.el7.x Mon Nov 2 05:53 - 05:53 (00:00)
shutdown system down 3.10.0-229.4.2.e Thu Oct 1 05:29 - 05:29 (00:00)
shutdown system down 3.10.0-229.el7.x Tue Sep 29 08:49 - 08:49 (00:00)
shutdown system down 3.10.0-229.el7.x Tue Sep 29 08:25 - 08:25 (00:00)
If you want only Last shutdown or reboot of server
[root@gw-server ~]# last -x | grep reboot | head -1
reboot system boot 3.10.0-514.26.2. Thu Aug 3 09:59 - 08:24 (100+23:24)
[root@gw-server ~]# last -x | grep shutdown | head -1
shutdown system down 3.10.0-514.26.2. Thu Aug 3 09:59 - 09:59 (00:00)
[root@gw-server ~]# date
Sun Nov 12 08:24:48 EST 2017
[root@gw-server ~]#
Post a Comment