Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command/s needed

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0


I need to write a script to find the downtime on my Solaris 7 server.

Please give me the command or commands needed to do this so I can then write my script based on these commands.
 
There are no actual commands to show downtime however you can display system uptime with the 'uptime' command and you can check system reboots with the 'last' command.

Alternatively if you want to record uptime over a period, maybe a cron job to write the output of 'uptime' to a log file may help - say every ten minutes or whatever timescale suits your requirements.
 
If you have two servers, you could use each one to monitor the other one by running this script from a cron.

#!/bin/ksh
ping other_server
if [[ $? = 0 ]] then
echo `date` "Other_server is up" >> logfile
else
echo `date` "Other_server is down" >> logfile
fi

Note however that this would also record network failures as server down.

 
I looked at my last output and dont see anywhere it says the server was rebooted.
Any key words to look for in there??
Thanks
 
If you want to know when the system was rebooted try either:

uptime

or

who -b Regards,
Chuck
 
It will show 'reboot' in the user name column. However it is possible that you have a cron job which is cleaning up the 'last' file /var/adm/wtmpx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top