Script to find “How much time taken for Server Reboot?” in Linux

Posted: September 8, 2015 in Amount of Reboot Time, Shell Script

Script :


#script to find out how much time tokk for previous reboot


echo -e “\n\tScript to find How much time taken Linux Server for last Reboot\n”

#BT = Server Boot Time After Reboot
BT=`last -F reboot | head -n 1 | awk ‘{print $5,$6,$7,$8,$9}’`

#RT = Server Rebooted time
RT=`last -F reboot | head -n 2 | awk ‘{print $11,$12,$13,$14,$15}’| tail -1`

echo -e  “Server Boot Time after Reboot = $BT”;
echo -e  “Server Rebooted Time          = $RT”;

#Note below output is should print the value between different date also Example JAN 10 23:59:21 server rebooted again server is came up at JAN 11 00:04:54 it should calculate the difference

echo -e “\nAmount of Time Reboot (seconds)  = $(( $(date -ud “$BT” +’%s’) – $(date -ud “$RT” +’%s’) ))Sec” ;

echo $(( $(date -ud “$BT” +’%s’) – $(date -ud “$RT” +’%s’) )) > out.txt

seconds=`cat /root/out.txt`

echo “Amount of Time Reboot (MM:SS)    = $((seconds/60))Min $((seconds%60))Sec”

echo “Amount of Time Reboot (HH:MM:SS) = $(date -d @$(( $(date -d “$BT” +%s) – $(date -d “$RT” +%s) )) -u +’%H:%M:%S’)”


Run :[root@test ~]# ./


Output :


  1. Hi there, just became alert to your blog through Google, and found
    that it is truly informative. I am going to watch out for brussels.
    I’ll be grateful if you continue this in future. Lots of people will be benefited from your writing.


  2. If you wish for to grow your knowledge only keep visiting this web page and be updated with the most up-to-date news update
    posted here.

  3. great post, very informative. I ponder why the opposite specialists of this sector do not understand this.
    You must continue your writing. I’m confident, you have a
    great readers’ base already!

  4. ӏ could not resist commenting. Perfectⅼy written!

  5. Joal says:

    Thank you for your script Keep this work!!

  6. I’m more than happy to uncover this website. I need to to thank you for ones time for this fantastic read!!

    I definitely enjoyed every part of it and
    i also have you saved to fav to see new stuff on your web site.

  7. AndreaTSidhu says:

    Hi there! This is my 1st comment here so I just wanted to give a
    quick shout out and say I really enjoy reading your blog posts.

    Can you recommend any other blogs/websites/forums that
    cover the same topics? Appreciate it!

  8. CalvinOSysak says:

    I all the time utilized to read post in news papers the
    good news is while i am a person of internet so from now I am just using net for
    articles or reviews, as a result of web.

  9. xmodgames says:

    Thanks to my father who told me about this webpage, this weblog is
    actually awesome.

  10. Wow, this piece of writing iis fastidious, my sister is anaalyzing these things, so I am going to inform her.

  11. Quality articles or reviews is the key to attract the people to
    go to see the web page, that’s what this web page is providing.

  12. I am regular reader, how are you everybody? This article posted at this
    web site is really nice.

  13. I every time emailed this web site post page to all my contacts, as if like to read
    it then my friends will too.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s