I was looking for a solution on how to display the /usr/bin/uptime command in PHP and I came across this simple yet very useful script for me since sometimes I don’t want to login or anything.
So to display your box’s uptime just create a file called uptime.php or whatever you want to call it. And then paste the following code.
<?php
$uptime = passthru ("/usr/bin/uptime");
echo "$uptime";
?>
Take note that this has no formatting whatsoever, so that’s all up to you if you want to use a style sheet or not.
If you can’t see the uptime command being displayed make sure that passthru is not in your disable_functions in your php.ini file (Thanks to Luis ‘SquarePants’ Valecillos for pointing this out).
Tags: PHP