Within my PHP script, I want to do an exec(), but I don't want PHP to wait for the console to finish executing the program. I just want to start the program with exec(), and have it spawn off a command console that will run the program in the console and then the PHP thread would finish, and then close out.

The problem is that my PHP thread is waiting for the exec() to finish. I just want to run my command line program, and then have PHP "keep going" so it doesn't have to wait for results. I don't need the results of the program output.

Please help!
Jon

    cant do better than quoting this from the manual

    In order to execute a command have have it not hang your php script while it runs, the program you run must not output back to php. To do this, redirect both stdout and stderr to /dev/null, then background it.

    /dev/null 2>&1 &

    In order to execute a command and have it spawned off as another process that is not dependent on the apache thread to keep running (will not die if somebody cancels the page) run this:

    exec('bash -c "exec nohup setsid your_command > /dev/null 2>&1 &"');

      7 days later
      Write a Reply...