Answered by:
How do I determine how many time my linux machine has restarted?

Question
-
Thanks in advance!!!Wednesday, June 6, 2007 8:59 AM
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 Snippetcat /home/you/numofboots.txt | xargs expr 1 + > tmp.txt
mv -f tmp.txt /home/you/numofboots.txt
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...
ThanksMonday, 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 Snippetcat /home/you/numofboots.txt | xargs expr 1 + > tmp.txt
mv -f tmp.txt /home/you/numofboots.txt
Monday, June 11, 2007 5:28 PM -
Look at /var/log/boot.log
And also /var/log/messagesWednesday, September 12, 2007 1:30 PM