|
Posted by petersprc on 08/12/07 19:25
The system could also run your command for you when you use the at
command.
For example, this page launch.php calls the at command, which loads
the web page batch.php in the background:
<?
// File: launch.php
function launch($url)
{
$cmd = 'echo lynx -source ' . escapeshellarg($url) .
' | at now 2>&1';
exec($cmd, $output, $exitCode);
if ($exitCode != 0) {
$msg = "Command \"$cmd\" failed with exit code $exitCode: ";
$msg .= join("\n", $output);
trigger_error($msg, E_USER_ERROR);
return false;
}
return true;
}
$done = false;
if (isset($_GET['btn'])) {
$url = 'http://my.tld/batch.php';
$done = launch($url);
}
?>
<h3>Launch</h3>
<? if ($done) { ?>
<p>Command launched in background.</p>
<? } ?>
<form action="launch.php">
<input type=submit name=btn value=" Go ">
</form>
On Aug 11, 12:47 pm, "Fabio" <znt.fa...@virgilio.it> wrote:
> Hi all
>
> There is a way to exec a function asynchronously?
> I need to exec a function that is too slow but for me can be executed in the
> background... there is no way???
>
> Thanks
Navigation:
[Reply to this message]
|