Run PHP-Script in Background

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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

Thanks for any ideas.


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.

Re: Run PHP-Script in Background

Quoted text here. Click to load it

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

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.

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

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

Quoted text here. Click to load it

Re: Run PHP-Script in Background

Thomas wrote:
Quoted text here. Click to load it

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


Site Timeline