简体   繁体   中英

Run command from PHP, exit script, but keep command running

I am running a PHP script that uses the passthru function to run system commands in the background. By redirecting the output and putting the & at the end of the command, the script is able to continue executing without waiting for the system command to finish. However, the PHP script itself does not exit until all commands are complete. Is there a way that the PHP script can start a system command and then not have to wait for that command to finish before exiting?

Have you tried using nohup?

Instead of

my_command >/dev/null &

do

nohup mycommand >/dev/null &

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