hi guys i have a php file (containing a delayed loop which lasts for hours) and i want to to run without having to keep the browser window open is it possible to pass a value (an integer for example) from a web page and that script starts execution on the background, no matter if the browser is closed ?
[man]ignore_user_abort[/man]
[man]set_time_limit[/man]
If u have the possibility to set a cronjob on your server, that will do what u want whenever u want...
thanks for the replies i was thinking executing the script as a service from a web form and stuff... but it was simple realy. a popup window with <?php ignore_user_abort(true); $newsletter = new Newsletter(); if ($GET['newsletter_id'] > 0) { echo "Started sending, you can close this window now.<br />"; sleep(1); $newsletter->SendNewsletter($GET['newsletter_id']); } ?> did it 🙂 thanks again
Wow... I've never known about [man]ignore_user_abort/man heh. I always just fork the process into the background:
exec('/path/to/php -f myFile.php &');
Just watch out you don't include any infinite loops :p
Then you could end up with the same php file being opened 100+ times :p
I've done that a few times on my computer, I wondered why it was starting to run slow. Lol.