≡ Menu

Linux last Reboot Time and Date Find Out Command

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.

who command

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         Sun Apr 30 15:08 - 16:22  (01:13)

The last command 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         Sun Apr 30 13:31 - 15:08  (01:37)


  • -x: Display the system shutdown entries and run level changes.

For more information read last command man page.

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 16 comments… add one }

  • jamshid February 22, 2007, 11:29 am

    On my FC5 system instead of
    last reboot | head -1
    I can type
    last reboot -1

    • Roshan October 28, 2014, 7:32 am

      Please give a try by your own!! I think it will not work dude.

  • diana October 15, 2007, 12:57 pm

    i couldn’t find out the error. please help me.

    #Send list of users logged on to server via email
    59 11 * * * last | grep date ‘+%a %b %d’ > /tmp/users.out ; mail -s “Users Logged Today” ephrondiana@gmail.com

    when i tried to execute,
    $ last |grep date ‘+%a %b %d’
    i got no such file or directory error.

  • nixCraft October 15, 2007, 1:06 pm

    Should be..

    59 11 * * * last | grep $(date '+%a %b %d') > /tmp/users.out ; mail -s “Users Logged"
  • diana October 15, 2007, 1:25 pm

    thanks a lot vivek.i din’t expect this much fast reply.But unfortunately when i execute,
    $ last | grep $(date ‘+%a %b %d’)
    i couldn’t get anything.Please help

  • nixCraft October 15, 2007, 2:12 pm

    My bad…I forgot to include double quote …

    59 11 * * * last | grep "$(date '+%a %b %d')" > /tmp/users.out ; mail -s “Users Logged"

    Also you may wanna try out:

    last -t yyyymmddhhmmss


  • diana October 16, 2007, 3:45 am

    Thanks vivek.its working great…..

  • xera December 6, 2009, 3:04 pm

    the command “last reboot” worked for me, on my mac!

  • Ajeet August 17, 2010, 10:12 am

    Can we find who rebooted the linux box?

    • Nick March 16, 2011, 11:48 pm

      In order to track who rebooted a linux machine, I would:
      – disable root logins; many users sharing root is bad
      – create a list of sudoers, so only people listed there could shutdown / reboot / halt
      – /var/log/messages would contain traces of who ran sudo shutdown -r now or such

  • L_kernel September 23, 2010, 1:38 pm

    Thanks a lot!
    I help me!

  • Sam Hocevar March 28, 2011, 2:34 pm

    wtmp is rotated by the system, so the last solution will stop working. I believe the most reliable solution is:

    date -d "`cut -f1 -d. /proc/uptime` seconds ago"
    • lavermil June 13, 2011, 9:02 pm

      The uptime idea from Sam is nice but really that just returns the uptime (same as the uptime command) in date format.

  • alexander November 17, 2011, 8:47 pm

    last | grep USERNAME | grep tty | head -n 1 |awk -F ‘ ‘ ‘{print $7}’

  • Albert Diones March 4, 2015, 9:07 pm

    Is there any way to check if the system is currently rebooting? Or shutting down

    I made a cron job that will reboot the server when a specific file exists (deleting that file too of course)
    So that I can use php to make it and signal a reboot when needed
    When cron job fires, the few seconds of shutting down will trigger database connection error
    So I want to know if there is any standard way of knowing the system is rebooting aside from making another file that existence signals “server is rebooting” (which I don’t know how to delete when server is back up anyway)

  • Velma March 23, 2015, 7:18 am

    Thank u :) for info

Leave a Comment