vcv Posted April 28, 2008 Share Posted April 28, 2008 hello all, I have a problem that google has been unable to solve for me. I need a php script to run an external program and simply continue execution without waiting for its completion. Currently i am calling "system($cmd);" where that then runs a java program to create and send an xmlrpc request to the cluster that then performs calculations for at least an hour. What I would like is it to just call $cmd and not bother waitiing on it. thank you Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 If your server is running linux ( it better be!! ) you can add this char '&' at the end of your command line and it will run the task in the background. Also, remember to redirect all outputs to a log file or /dev/null or else the PHP script will have to wait for the programs output. Quote Link to comment Share on other sites More sharing options...
effigy Posted April 28, 2008 Share Posted April 28, 2008 pcntl_fork Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 pcntl_fork will fork the running PHP script. I think that he is wanting to run a seperate program. Quote Link to comment Share on other sites More sharing options...
vcv Posted April 28, 2008 Author Share Posted April 28, 2008 thank you both for your replies. I had already tried the & but didnt route the output to /dev/null and doing so made it work like a charm . So for future posterity, my solution is: system($cmd." > /dev/null 2>&1 &"); I didnt try the fork but im sure that could work if i just didnt wait for the child. Thank you very much for ya'lls help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.