Peter van Schie wrote:[color=blue]
> Peter van Schie wrote:
>[color=green]
>> You could use /proc/uptime to retrieve it.
>> For a php example, check this out:
>>
>>
http://www.xenocafe.com/tutorials/ph...time/index.php
>>[/color]
>
> I just noticed that that tutorial has a lot of unnecessary mumbo jumbo
> in it.
> Here's a simpler code snippet of how to use /proc/uptime:
>
> <?php
> $uptime = shell_exec("cut -d. -f1 /proc/uptime");
> $days = floor($uptime / 60 / 60 / 24);
> $hours = $uptime / 60 / 60 % 24;
> $mins = $uptime / 60 % 60;
> $secs = $uptime % 60;
> echo 'Uptime is: ' . $days . ' days ' . $hours . ' hours ' . $mins
> minutes . ' and ' . $secs . ' seconds';
> ?>
>[/color]
Thanks, that code (with a few tweaks involving the minutes text-oops)
gives me:
Uptime is: 5 days 21 hours 34 minutes and 44 seconds
which is the same as what my other script was giving me and is the
uptime since the last reboot. Obviously this posses problems when trying
to calculate a percentage.
Thanks
Ben