I have do a search of how to detect the a command success or not in bash. For example:
https://askubuntu.com/questions/29370/how-to-check-if-a-command-succeeded/29379#29379
Some one suggested that using $? to detect a command is success or not.
I want do a lot of task and check if the task is works OK.
At first, I do run and check one by one. It is in a serial way.
# first
./a.out
if [ "$?" -ne "0" ]; then
echo "code error!"
fi
# second
./b.out
if [ "$?" -ne "0" ]; then
echo "code error!"
fi
# third
./c.out
if [ "$?" -ne "0" ]; then
echo "code error!"
fi
There is no denpency between task, so I want to transfer the script to a parallel way. I want submit the command in the background and do the check after command the finished. I want something like follow
# submit all task to back ground
./a.out &
./b.out &
./c.out &
# wait they all finished ...
# wait a
# wait b
# wait c
# do some check ...
# check a
# check b
# check c
I don't know how to realize that ...
Cound any one help me? Thank you for your time.
$?like that. Just use the exit status directly, e.g.if ! ./a.out; then ...