Get PID of background process started in a bash script started from php function

one text

I have a php function that runs a bash script script.sh like this:

<?php
    function startScript() {
      shell_exec("/srv/mr/scripts/script.sh");
      return true;
    }
?>

and the script.sh runs a series of long running commands that run one after another.

script.sh:

#!/bin/bash

thisLog="/path/to/logFile.txt"
( (cmd1); sleep 10; (cmd2); sleep 10; (cmd3); ) &>/dev/null & disown
echo $$ >>pid
echo $! >>pid
echo $BASHPID >>pid
jobs -p >>pid
someothercmd
exit 0

I am trying to get the PID of cmd1 but all I could get was the PID of script.sh or some other process that was already completed.

I even tried putting those "echo $$" and "echo $!" and "echo $BASHPID" before "cmd1" with no luck. How can I get the PID of cmd1?

Source