Complete script even when user is not online
Is there a way to go through a script when a user is offline?
Cron jobs allow a script to run at a certain interval for as long as you need. It can be, for example, every day at 2am. Scheduled Tasks are the equivalent on windows. (Cron jobs are just for linux I believe. Or maybe it's apache. Not too important.)
There's another option which sounds more like what you said, if you meant this:
That's a very interesting feature and potentially very powerful and even dangerous. It allows a script to continue despite a user disconnecting (such as closing the page while it is loading). If you include infinite loops in your PHP this can make a truly never-ending execution, and that could cause problems on the server.
If you might run into a situation where you have these ghost executions still going without any limits, it would probably be a good idea to have a backup plan, such as a way to turn them off automatically-- add into each iteration of the infinite loop a check to see if a certain value in the database is set. If it is set, then stop the execution. This is your "off" button. And if you ever have extra scripts running, you can set the database that way and it will catch them in the next loop.
This function looks like lots of fun and actually could replace cron jobs in an interesting way. Just set the script to sleep for a certain interview then go through the loop again. Instant cron job. But again it's crucial to add in a way to stop this endless execution. Of course to start it all you need to do is load the page in your browser and then close the window.
You're probably looking for cron jobs, actually, though...
Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum