Invoke external shell script from PHP and get its process ID

$command =  'yourcommand' . ' > /dev/null 2>&1 & echo $!; ';

$pid = exec($command, $output);

var_dump($pid);

Leave a Comment