Jas
03-13-2008, 06:44 PM
I have a php script that is suppose to run in the background of the server on a very very long loop. The problem is that a user has to call the script for it to begin. Is there a way to cut the users connection to the script? In other words:
<?php
ignore_user_abort(true);
set_time_limit(0);
header("Location: ./page.php"); //CUT THE USER'S CONNECTION HERE!
$x=0;
do{
$x++;
sleep(60);
}while($x<1000)
?>
Otherwise the user has to push the stop button or wait until the timer runs out. Right now the header does nothing until the loop ends-- and the loop doesn't end before the user times out.
Or perhaps there is a way to run the script in another way, such as via the system() function? (Again, though, it would need to be called through a php script and redirect the user rather then having them stick around until they time out.)
<?php
ignore_user_abort(true);
set_time_limit(0);
header("Location: ./page.php"); //CUT THE USER'S CONNECTION HERE!
$x=0;
do{
$x++;
sleep(60);
}while($x<1000)
?>
Otherwise the user has to push the stop button or wait until the timer runs out. Right now the header does nothing until the loop ends-- and the loop doesn't end before the user times out.
Or perhaps there is a way to run the script in another way, such as via the system() function? (Again, though, it would need to be called through a php script and redirect the user rather then having them stick around until they time out.)