I have this code:
for job in `jobs -p`; do
code=0;
wait ${job} || code=$?
if [[ "${code}" != "0" ]]; then
echo "At least one job failed with exit code => ${code}" ;
exit 1;
fi
done
right after the line: echo "At least one job failed with exit code => ${CODE}" ;
I want to add a line that logs the command that failed, something like this:
for job in `jobs -p`; do
code=0;
wait ${job} || code=$?
if [[ "${code}" != "0" ]]; then
echo "At least one job failed with exit code => ${code}" ;
echo "The job that failed was $(ps -p ${job})"
exit 1;
fi
done
not that a job
is just the pid of the subprocess. The problem is that this line:
echo "The job that failed was $(ps -p ${job})"
doesn't really about anything - I need the actually command that was run, given the pid=job.