Run PHP-Script in Background

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas

    #1

    Run PHP-Script in Background

    I am using php 5.0.4 under IIS 6 under Windows Server 2003 and want to
    run a php-script as a separate process. This schript dies not have any
    output. I tried several variants without success:

    exec("c/php5/php.exe path/to/script parameters &") will run the schript
    but will wait until the schript finished processing.

    exec("c/php5/php.exe path/to/script parameters > null &") gives me the
    error message "The specified CGI application exceeded the allowed time
    for processing. The server has deleted the process."

    Dealing with other variants of php cli procesors like php-win.exe gave
    the same result. Also trying to use the start command did not help. My
    head is burned out, what else could run my script under this
    environment?

    Thanks for any ideas.

    Thomas

  • noor.rahman@gmail.com

    #2
    Re: Run PHP-Script in Background

    Do you need your script to run constantly? Or should it run only once
    after x-many days/hours/minutes?

    I had a similar task to do in a W2K environment. I wrote a master PHP
    script with set timings on when to run each secondary script bazed on
    time of day. Then I just put that mster script in the Windows
    scheduler so it runs every hour... That did my job but I don't know if
    that's what you are looking for.

    Comment

    • Thomas

      #3
      Re: Run PHP-Script in Background

      > Do you need your script to run constantly? Or should it run only once

      It should run only once, and I need to send a parameter with. It's
      actually a script which would run too long to wait on with the browser,
      so it would run into the timeout limits. So I could look at the
      progress with another script that runs periodically using a javascript
      timer.

      Comment

      • noor.rahman@gmail.com

        #4
        Re: Run PHP-Script in Background

        I can't think of how you can pass a parameter... perhaps through a
        database... but for the timeout issue, you can dynamically set how long
        you want your script to run.

        Comment

        • David

          #5
          Re: Run PHP-Script in Background

          Do you want to run the script as an INDEPENDENT process or start from
          the web app and wait for the results?

          If this is independent, maybe write the request in .net and update a
          database?

          You could also write a service on the machine to look for requests and
          then process them.



          On 11 Sep 2005 10:20:27 -0700, "Thomas" <tj@3sweb.net > wrote:
          [color=blue]
          >I am using php 5.0.4 under IIS 6 under Windows Server 2003 and want to
          >run a php-script as a separate process. This schript dies not have any
          >output. I tried several variants without success:
          >
          >exec("c/php5/php.exe path/to/script parameters &") will run the schript
          >but will wait until the schript finished processing.
          >
          >exec("c/php5/php.exe path/to/script parameters > null &") gives me the
          >error message "The specified CGI application exceeded the allowed time
          >for processing. The server has deleted the process."
          >
          >Dealing with other variants of php cli procesors like php-win.exe gave
          >the same result. Also trying to use the start command did not help. My
          >head is burned out, what else could run my script under this
          >environment?
          >
          >Thanks for any ideas.
          >
          >Thomas[/color]

          Comment

          • NC

            #6
            Re: Run PHP-Script in Background

            Thomas wrote:[color=blue]
            >
            > I am using php 5.0.4 under IIS 6 under Windows Server 2003 and want to
            > run a php-script as a separate process. This schript dies not have any
            > output. I tried several variants without success:
            >
            > exec("c/php5/php.exe path/to/script parameters &") will run the schript
            > but will wait until the schript finished processing.[/color]

            This is not Unix; "&" does not work here. Try this:

            exec('start c:/php5/php.exe path/to/script parameters');

            For more information, type "help start" at your Windows command
            prompt.

            Cheers,
            NC

            Comment

            Working...