Jump to content

New to this, simple question.


allower

Recommended Posts

I need a php script to print uptime on my server to a html file. All i found is this code under here, what should I do from here to get the uptime to show in a htmlfile.

 

Thankful for any help.

 

/Christian, Sweden.

 

<?php
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";
?>

Link to comment
https://forums.phpfreaks.com/topic/192294-new-to-this-simple-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.