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.

  14. 人胎盤 says:

    Hello to every one, the contents existing at this website
    are actually awesome for people knowledge, well, keep up
    the good work fellows.

  15. Nice post. I was checking constantly this blog and I’m impressed!
    Very useful information specifically the closing section 🙂 I maintain such information a lot.
    I used to be seeking this certain information for a long time.
    Thanks and good luck.

  16. After checking out a few of the articles on your web site, I
    honestly like your way of writing a blog. I bookmarked it to my bookmark
    webpage list and will be checking back in the near future.
    Take a look at my website as well and let me know your

  17. I used to be able to find good advice from your blog posts.

  18. Definitely believe that which you said. Your favorite
    justification seemed to be on the web the easiest thing
    to be aware of. I say to you, I definitely get annoyed while people think
    about worries that they just do not know
    about. You managed to hit the nail upon the top and defined out
    the whole thing without having side-effects , people can take a
    signal. Will likely be back to get more. Thanks

  19. Highly energetic article, I enjoyed that bit. Will there be a part 2?

  20. says:

    What’s up Dear, are you really visiting this website regularly, if so afterward
    you will absolutely take nice know-how.

  21. We are a group of volunteers and opening a new scheme in our
    community. Your website provided us with useful information to work
    on. You have done a formidable activity and our whole community will probably
    be grateful to you.

  22. Great article, exactly what I needed.

  23. Hey There. I found your blog using msn. This is a really well written article.
    I will make sure to bookmark it and return to read
    more of your useful info. Thanks for the post. I’ll certainly comeback.

  24. I like the valuable info you supply to your articles.

    I will bookmark your blog and take a look at once more
    here frequently. I am reasonably sure I’ll learn many new stuff right right here!
    Best of luck for the next!

  25. Every weekend i used to pay a visit this web site, because i wish for
    enjoyment, for the reason that this this site conations
    genuinely good funny material 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