Saffas Web - UK Web Hosting Services
Billing Centre Help Centre Shopping Cart
Sales and Support
Saffas Web Saffas SEO Saffas Voice Saffas Telecom
  Advanced AntiSpam   |  WordPress Blog   |  Joomla CMS   |  ZenCart Shop  |  Cheap Domains Why clients love Saffas Web
 

Design - Server Uptime

Code to monitor 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";
?>


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.

 Easy Web Hosting | Site Map | Why We're Best | Newsletter | Support | Recommend This Page
POLDINGS
billing centre
shopping cart
support tickets
Saffas Web
uk web hosting
domain names
custom design
Saffas SEO
free seo advice
submit your site
seo help articles
Saffas Voice
talking animation
computer voices
custom characters
Saffas Telecom
0844 switchboard
conference calls
telecom resellers
Poldings Ltd, The Hub, Farnborough Business Park, Hampshire, GU14 7JF, England, UK. Phone 0844 884 9100