I am running two mysqlsp in a bash script. I want to start both of them simultaneously (they are running in remote servers) and put them in background, once completed proceed to next step. I want to get the exit status of both(to know in case error happened). With this in mind I have tried below with sleep command, but not working.Editing as per Jeff Schaller's answer : Below are what I have tried.givinv@87-109:~$ sleep5 & PID5=$!; exit5=$?; sleep 4 & PID4=$!; exit4=$?; wait $PID5 $PID4; echo $exit5 $exit4[1] 29530[2] 29531No command 'sleep5' found, did you mean: Command 'sleep' from package 'coreutils' (main)sleep5: command not found[1]-  Exit 127                sleep5[2]+  Done                    sleep 40 0givinv@87-109:~$ unset exit5 exit4givinv@87-109:~$ sleep5 & exit5=$?;PID5=$!; sleep 4 & exit4=$?;PID4=$!; wait $PID5 $PID4; echo $exit5 $exit4[1] 29535[2] 29536No command 'sleep5' found, did you mean: Command 'sleep' from package 'coreutils' (main)sleep5: command not found[1]-  Exit 127                sleep5[2]+  Done                    sleep 40 0givinv@87-109:~$ I knowingly put sleep5(error command), but still getting 0 as exit status. When I run above commands, I see a line like [1]- Exit 127 sleep5. Is it possible to trap that while running from script? How to get the exit status of two commands that run simultaneously?
How to get exit status of a background process?
linux;bash;background process;return status