简体   繁体   中英

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

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM