I'm new to bash scripting. I wrote a script that runs 4 Python scripts in parallel. These scripts make API calls to bring data to the local machine, sometimes these scripts fail, and get only a fraction of the data.
How can I make sure that if a script fails, execution of bash script will start over until the script get all the data?
#!/bin/bash
scripts=/root/scripts
data=/root/data
date=$(date +"%Y_%m_%d")
$scripts/filesystem.py > $data/filesystem_$date.log &
$scripts/cpu.py > $data/cpu_$date.log &
$scripts/memoria.py > $data/memoria_$date.log &
$scripts/swap.py > $data/swap_$date.log &
wait
UPDATE
based on your comments the script will be something like this? but the parallel execution will still work? the wait command at the end is necessary?
until [ "$?" -eq "0" ]
do
$scripts/filesystem.py > $datos/filesystem_$fecha.log &
done
until [ "$?" -eq "0" ]
do
$scripts/cpu.py > $datos/cpu_$fecha.log &
done
until [ "$?" -eq "0" ]
do
$scripts/memoria.py > $datos/memoria_$fecha.log &
done
until [ "$?" -eq "0" ]
do
$scripts/swap.py > $datos/swap_$fecha.log &
done
wait