Results 1 to 3 of 3

Thread: Complete script even when user is not online

  1. #1
    Join Date
    Jul 2011
    Thanked 1 Time in 1 Post

    Default Complete script even when user is not online

    Is there a way to go through a script when a user is offline?

  2. #2
    Join Date
    Mar 2007
    New York, NY
    Thanked 66 Times in 66 Posts


    Yes. Use a cron job.
    - Josh

  3. #3
    Join Date
    Mar 2006
    Illinois, USA
    Thanked 690 Times in 678 Posts


    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts