exec background process

This is a discussion on exec background process within the PHP Language forums, part of the PHP Programming Forums category; I want have PHP call another process (another PHP script at the moment but it may end up being a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-10-2003
Matt
 
Posts: n/a
Default exec background process

I want have PHP call another process (another PHP script at the moment
but it may end up being a binary) in the background and not wait for
process to complete, but rather instantly jump the the next line of
code.

I've tried things like:

exec("./script.php &"); // script.php has executable permissions set
exec("at -f ./script.php now"); // and #!/usr/bin/php at the top of
the code

Neither seem to work. They both execute script.php, but both hang
around until script.php has completed.

Any ideas?
Reply With Quote
  #2 (permalink)  
Old 09-11-2003
Jon Kraft
 
Posts: n/a
Default Re: exec background process

Matt <google@mralston.com> wrote:

> I want have PHP call another process (another PHP script at the moment
> but it may end up being a binary) in the background and not wait for
> process to complete, but rather instantly jump the the next line of
> code.
>
> I've tried things like:
>
> exec("./script.php &"); // script.php has executable permissions set
> exec("at -f ./script.php now"); // and #!/usr/bin/php at the top of
> the code
>
> Neither seem to work. They both execute script.php, but both hang
> around until script.php has completed.


Hi Matt,

You could use proc_open for this:

proc_close(proc_open ("./script.php &", array(), $foo));

The empty array for the output specs prevents opening any pipes to the new
process, so proc_open doesn't wait for the execution of script.php to
finish - the last parameter is just there because it has to be.
proc_close() closes the process immediately, so your PHP script doesn't
stop.

HTH;
JOn
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0