Run bash script with php without waiting

I am running a bash script from php using shell_exec. But the php script is waiting for the shell to complete the script.

Is there any way to invoke a bash script without waiting. Both:

exec
shell_exec

waiting for the completion of the bash script. I am running linux btw.

+5
source share
2 answers

This should work:

exec('/your/command /dev/null 2>/dev/null &');

+5
source

when calling your application bash script and therefore it will work in the background which is the easiest way if you do not need any output

shell_exec("/bin/bash /path/to/script.sh &"); 
+1
source

All Articles