[icon type="linux"]So, how do you find Linux or UNIX-like systems last reboot/shutdown date and time? The last utility will either list the sessions of specified users, ttys, and hosts, in reverse time order, or list the users logged in at a specified date and time. Each line of output contains the user name, the tty from which the session was conducted, any hostname, the start and stop times for the session, and the duration of the session.
You need to use who command, to print who is logged on. It also displays the time of last system boot. Use last command to display system reboot and shutdown date and time.
$ who –b
system boot Apr 30 15:08
Use last command to display listing of last logged in users and system last reboot time and date:
$ last reboot | less
Or, better try:
$ last reboot | head -1
reboot system boot 184.108.40.206 Sun Apr 30 15:08 - 16:22 (01:13)
The [nixcmd name="last"] searches back through the file /var/log/wtmp and displays a list of all users logged in (and out) since that file was created. The pseudo user reboot logs in each time the system is rebooted. Thus last reboot command will show a log of all reboots since the log file was created.
Finding systems last shutdown date and time
To display last shutdown date and time use the following command:
$ last -x|grep shutdown | head -1
shutdown system down 220.127.116.11 Sun Apr 30 13:31 - 15:08 (01:37)
- -x: Display the system shutdown entries and run level changes.
For more information read [man text="last command man page"]last(1)[/man].