exec() in background

They have: 173 posts

Joined: Feb 2005

How can I execute an external program and let it run in the background, rather than waiting for it to finish before the page is "done"?

He has: 1,758 posts

Joined: Jul 2002

I'm pretty sure the method you are talking about is called 'forking'. In unix you can usually run most commands in the background, simply execute the program using the standard unix syntax between backticks (`) with the necessary flags to run it in the background and that should work...

Actually... I've just done a bit more research. It would appear that to make a process run in the background you just put an ampersand (&) at the end of the line.

so your script could look like:

<?php
   
`process_name &`;
?>

Andy

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.