Uptime posted to html via PHP?
Anyone know the command to post system uptime to a page?
Would like to post it on my front page. Isn't is like $PHP_Uptime er something? im looking but haven't found anything yet. Oh, except to echo end-users browser/os type :) neat stuff. |
http://freshmeat.net/projects/phpuptime/?topic_id=862
reports the uptime, and makes it an image, you could edit the script Shak |
That's pretty nicely done. The only problem is it doesn't extract the number of days properly. The number of days doesn't always start on the 13th character. And it only reads 2 characters meaning you could never have an uptime greater then 99 days. But it shouldn't be too hard to modify that. You could remove the line $uptime = (exec("uptime"));
and replace the $up = line with the following one: $up = (exec("uptime | sed 's/.*up //' | sed 's/ days.*//'")); Haven't tried it out but something like that should work. |
|
got it!
<?php $fp = popen("/usr/bin/uptime", "r"); while($line = fgets($fp, 1024)): printf("%s<br>\n", $line); endwhile; pclose($fp); ?> works for me! but im interested in others :) thanks for the replies |
Well since the output of uptime is just one line, and you want to display the whole line anyway. Why don't you change it to:
<?php $up = exec("/usr/bin/uptime"); printf("%s<br>\n", $up); ?> |
All times are GMT -5. The time now is 01:31 AM. |