![]() |
Finding Uptime of Server.
Hi,
I would like to is it possible to find out uptime of server after server rebooting? |
the command last will give you info about the reboots.
From the other hand there is a command uptime. |
The command uptime will show you how long your system is up.
But I guess what you want to know is an overall uptime. Like 10mins up -> reboot -> 2days up -> reboot -> 3weeks up. To a total of 3weeks 2days and 10minutes. Right? Sorry but that is not possible with build in tools. You have to "manually" do the math and save this between reboots or similar. There are some threads here on LQ how to do this. |
Thanks Zhjim for your quick response.
|
Pan64 thanks for bringing up the last command. What I just found out is that the output lines of last with reboot on them also show you the time from when to when the system was up.
I learned something during my first cup of coffee. Must be a good day :) |
Little script to compute overall uptime
Code:
#!/bin/bash |
"last reboot" and "uptime" are good, but here's an alternative that I occassionally use now to find the 'uptime' of an individual process. (This process just happens to be init).
Code:
ps -p $(pidof -x init) -o lstartCredit goes to fernfrancis... |
Whuhu. last reboot is even better. Running on a server I also saw that I don't have days in my script. Editing in progress.
|
| All times are GMT -5. The time now is 09:29 PM. |