Hands-on task
Background jobs: wait and exit codes
/opt/batch/ has three jobs: job1.sh, job2.sh, job3.sh — each runs for a couple of seconds and exits with its own code. Write a script /root/run-jobs.sh that starts all three in parallel in the background, waits for each via wait by its PID, and writes the return codes to /root/codes.txt — one per line, in the order job1, job2, job3. Make the script executable and run it. The jobs in /opt/batch/ change, so don't write the codes into the script: it must work with any jobs.
- wait
- background jobs
- $!
- $?
- return codes