0

Possible Duplicate:
shell - get exit code of background process

I have a bash scripts which runs another bash script in the background (bash -i -c "blah &") the very first thing, and then continues with its own business!

The problem is how can I check at the very end, if the other script failed or not?

Community
  • 1
  • 1
MBZ
  • 24,505
  • 45
  • 111
  • 185

1 Answers1

0

After launching script in the background, remember its PID:

do_your_job &
your_job_pid=$!

At the very end, wait for this PID. The result code of wait would be the result code of background script.

wait $your_job_pid
echo "Returned $?"
Anton Kovalenko
  • 20,203
  • 2
  • 35
  • 68