allower Posted February 16, 2010 Share Posted February 16, 2010 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/192294-new-to-this-simple-question/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.