Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the system command with an ampersand at the end isn't running the process in the background

Tags:

php

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?

like image 248
Nathan Avatar asked Feb 24 '23 17:02

Nathan


1 Answers

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

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

like image 54
cweiske Avatar answered Feb 26 '23 08:02

cweiske