locked
How do I determine how many time my linux machine has restarted? RRS feed

Answers

  • If all you need is the number of times the system boots up (which I believe is what you mean by the number of times it restarts), you can simply add a script in /etc/rc.d/rc.sysinit (which is a file run on each bootup). The script should simply increment a counter present in a file. In this way, you can count the number of boots that have occurred at any time by looking at the file. 
    I think the following can achieve it:
    * Create a file called numofboots.txt somewhere (for this example I use /home/you/numofboots.txt) and store the number 0 (zero) alone in it.
    * Add these two lines to /etc/rc.d/rc.sysinit
    Code Snippet

    cat /home/you/numofboots.txt | xargs expr 1 + > tmp.txt

    mv -f tmp.txt /home/you/numofboots.txt

    Please let me know if there is a more elegant way to do it..
    Monday, June 11, 2007 5:28 PM

All replies

  • i don't think that this information is stored anywhere, in any file.
    or you can check the emails to the localhost.

    Wednesday, June 6, 2007 4:42 PM
  • U can check this out in log files.I did that with tools on linux world.If u need them i will post their links.
    Saturday, June 9, 2007 11:32 AM
  • ya i m interested in using that linux tools,so plz send me the links...

    Thanks
    Monday, June 11, 2007 8:57 AM
  • If all you need is the number of times the system boots up (which I believe is what you mean by the number of times it restarts), you can simply add a script in /etc/rc.d/rc.sysinit (which is a file run on each bootup). The script should simply increment a counter present in a file. In this way, you can count the number of boots that have occurred at any time by looking at the file. 
    I think the following can achieve it:
    * Create a file called numofboots.txt somewhere (for this example I use /home/you/numofboots.txt) and store the number 0 (zero) alone in it.
    * Add these two lines to /etc/rc.d/rc.sysinit
    Code Snippet

    cat /home/you/numofboots.txt | xargs expr 1 + > tmp.txt

    mv -f tmp.txt /home/you/numofboots.txt

    Please let me know if there is a more elegant way to do it..
    Monday, June 11, 2007 5:28 PM
  • Look at /var/log/boot.log

    And also /var/log/messages

    Wednesday, September 12, 2007 1:30 PM