Below is a script I made which will delay the page by 2 seconds however, although the page will be processed with the delay, you may find that the whole page may display at the same time (after 2 seconds).
<html>
<body>
<?php
$oldseconds=date(s);
if ($oldseconds==58)
{
$newseconds=='00';
} else
if ($oldseconds==59)
{
$newseconds=='01';
} else
{
$newseconds=$oldseconds+2;
}
while (date(s)!=$newseconds)
{
//anything before this loop may not be delayed
//anything after this loop will be delayed.
// But with some browsers or servers this
// loop will delay the entire page
}
//place below here what you want after 2 seconds
$cpu=exec('top -d 1 -n 1|grep Cpu | tail -n 1 | cut -c 25-33');
echo "The Current CPU Utilization is ".$cpu;
<?php
$mem=exec('top -n 1|grep Mem');
echo $mem;
?>
</body>
</html>
It looks like you have a syntax error in your PHP. That is probably why it is returning immediately.
PHP should wait for the exec() command to complete, unless you specified a background process with
& in the command.
Remove the <?php in:
echo "The Current CPU Utilization is ".$cpu;
<?php
$mem=exec('top -n 1|grep Mem');
ps:
Output can also be buffered by PHP and/or the sever. Use ob_flush() and flush() to flush the buffers.
IE6 also doesn't render any output until it receives 256 bytes.
You should make sure you have 256 bytes if you want to display in IE6.
if (strlen($content) < 256) {
$content = str_pad($content, 256); // IE hack
}
echo $content;
@ob_flush();
flush();
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
Offline 1,250 posts
since Sep 2005