简体   繁体   中英

How to execute shell command from php in background

How can I execute shell command in background using & at the end? I've try:

php -r "shell_exec('sleep 10 &');"

and

php -r "shell_exec('/bin/bash -c \"sleep 10 &\"');"

in both cases it pause for 10 seconds instead of just give the shell back and run sleep in background.

You have to reroute the output somewhere. Try something like this:

php -r "shell_exec('sleep 10 > /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