Tuesday, June 19, 2007

Find Total Number of Reboots for a Workstation or Server

Here's a quick and dirty way of checking how many times your server/workstation was rebooted. First, I obtained the total number of reboots since Oct and then obtained the total number for each month. Here's an example.

Total reboots
wtmp begins Sat Oct 22 20:10
# last | grep reboot | wc -l
19

Find the total number of reboots for each month
# for i in Oct Nov Dec Jan Feb Mar Apr May Jun
> do
> echo server was rebooted `last | grep $i | grep reboot | wc -l` in $i
> done
server was rebooted 10 in Oct
server was rebooted 3 in Nov
server was rebooted 0 in Dec
server was rebooted 0 in Jan
server was rebooted 1 in Feb
server was rebooted 0 in Mar
server was rebooted 1 in Apr
server was rebooted 3 in May
server was rebooted 1 in Jun

No comments: