简体   繁体   English

最后使用带有&符号的系统命令不会在后台运行该进程

[英]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.我正在打一个简单的电话来恢复 mysql 备份,这需要大约 45 分钟才能在我的一台服务器上完成。

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.您仍然拥有 output 管道(stdout && stderr)的“句柄”,可以完全防止后台运行。

append a > /dev/null 2>&1 to the end. append a > /dev/null 2>&1到最后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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