How to start script in the background (using exec())?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dmitry Pljonkin

    How to start script in the background (using exec())?

    Hi!

    I have some troubles trying to start php script using exec() and leave
    it running in the background.

    Manual says: "If you start a program using this function and want to
    leave it running in the background, you have to make sure that the
    output of that program is redirected to a file or some other output
    stream or else PHP will hang until the execution of the program ends."

    So, I'm doing this:
    exec("/usr/local/bin/php /mydir/myscript.php >/dev/null 2>/dev/null
    &");

    I don't recieve any output from "child" script, but "parent" script
    waits until "child" is doing its work.

    What should I do to achive my goal?

    --
    Adios!
Working...