So in general you can say exec('MyCommand &> /dev/null &')
in php and MyCommand
will be executed as a seperate process, so your primary php execution can continue on it's merry way.
Oddly, if you try to do this using Laravel's Artisan
, something goes sideways. For instance, exec('php artisan command &> /dev/null &')
results, surprisingly, in the process still just hanging until the artisan command finishes. If you wrap the artisan command in a bash script, it won't execute at all.
Why is this, and how can I execute an artisan command in a new, detached process?