PHP spawn process PHP spawn process php php

PHP spawn process


Use this code:

<?php exec('nohup /usr/bin/my-command > /dev/null 2>&1 &'); ?>

This forks the sub-process into the background and writes all of the output into /dev/null. That way PHP continues executing the script as if there won't be any output it has to wait for.


I would suggest you to use CRON if you need to start a process on a time basis.