Got a question? Need help? Search our knowledgebase
- 90% of answers are available here!
Access a wealth of web hosting topics
to help with general and specific hosting issues.
to help with general and specific hosting issues.
Let's see if we've got the right answers for you.
Just enter your keyword phrase and run your search.
Design
Check server uptime
The following code will display the time elapsed since the last server reboot ...
<?
function linuxUptime() {
$ut = strtok( exec( "cat /proc/uptime" ), "." );
$days = sprintf( "%2d", ($ut/(3600*24)) );
$hours = sprintf( "%2d", ( ($ut % (3600*24)) / 3600) );
$min = sprintf( "%2d", ($ut % (3600*24) % 3600)/60 );
$sec = sprintf( "%2d", ($ut % (3600*24) % 3600)%60 );
return array( $days, $hours, $min, $sec );
}
$ut = linuxUptime();
// If you would like to show the seconds as well just add [ , $ut[3] seconds ] after minutes.
echo "Time since last reboot: $ut[0] days, $ut[1] hours, $ut[2] minutes";
?>
function linuxUptime() {
$ut = strtok( exec( "cat /proc/uptime" ), "." );
$days = sprintf( "%2d", ($ut/(3600*24)) );
$hours = sprintf( "%2d", ( ($ut % (3600*24)) / 3600) );
$min = sprintf( "%2d", ($ut % (3600*24) % 3600)/60 );
$sec = sprintf( "%2d", ($ut % (3600*24) % 3600)%60 );
return array( $days, $hours, $min, $sec );
}
$ut = linuxUptime();
// If you would like to show the seconds as well just add [ , $ut[3] seconds ] after minutes.
echo "Time since last reboot: $ut[0] days, $ut[1] hours, $ut[2] minutes";
?>
Cut and paste the code into a php file named (something like) 'uptime.php' and then save it to the root directory of your website. Then when you visit the page (http://www.yoursite.com/uptime.php) it will show the time elapsed since the last server reboot.
All content by Poldings Limited
Web Hosting and Web Development since 2001
Select a different knowledgebase section ...
Home | Billing | Databases | Design | Domains | Email | Getting Started | Hosting | Resellers | Resources | Scripts | SEO | Support | Troubleshooting | Tutorials


Read what our customers have to say: Customer Comments