How to execute a script in background using exec() from php script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ksn2007
    New Member
    • Jan 2008
    • 13

    How to execute a script in background using exec() from php script

    Hi All,
    I have to run a shell script from my php script and while shell script is running I have to do some other tasks in my php script.To run the shell script I am using
    exec("sh myscript.sh &");
    The Next line in my php script got executed after the shell script completes its execution. I want the next line of my script got eecuted as soon as i start shell script.
    Please suggest me how can I run the shell script in background so that as soon as the shell script starts the exec command comes out.
    Thanks
    KSN
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    I think you need to use passthru() instead of exec()

    Comment

    Working...