4

I'm making a simple call to restore a mysql backup that takes about 45 minutes to complete on one of my servers.

system("mysql -u$user -p$pass $db < '$file' &");

Running it that way locks my browser and I have to wait until it's finished before I can do anything. This works fine on my other server. What settings could be preventing that from working on the first server?

2
  • This looks like on the one server system is waiting for the background task to complete, while on the other it doesn't. What Operating Systems are the two servers? Does the PHP version differ? Have you tried to put the command into a shell script and invoke it instead?
    – hakre
    Jun 29, 2011 at 11:53
  • The two servers are so ridiculously different I don't even know where to start. Which is why I was wondering if anyone knew of something specific that would cause this.
    – Nathan
    Jun 29, 2011 at 12:00

1 Answer 1

8

You still have the "handle" to the output pipes (stdout && stderr) which prevents backgrounding fully.

append a > /dev/null 2>&1 to the end.

2
  • I was under the impression that there was no output to redirect from that command.
    – Nathan
    Jun 29, 2011 at 12:00
  • It does not matter the program to be run outputs anything - it might do that, thus the output pipes are open.
    – cweiske
    Jun 29, 2011 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.