Hello All,
I need to run a set of scripts, say 50 of them, parallely. I'm running these 50 scripts, from inside a script with the help of 'nohup' command.
1.The fifty scripts are stored in a separate file.
2.In a master script, i'm reading every line of the file through loop and executing them.
3.The master script should succeed, if and only if, all the 50 scripts that has been called succeeds. Or else should fail.(Exit 0)
So far, this is what i have tried :
failcount=0
passcount=0
while read line; do
nohup sh $line &
PID=$(echo $!)
wait $PID
status=$(echo $?)
if [ $status -eq 100 ]
then
echo "Script FAILED." >> ${logfile}
failcount=$((failcount+1))
elif [ $status -eq 0 ]
then
echo "Script SUCCEEDED." >> ${logfile}
passcount=$((passcount+1))
fi
done < /$PATH/script.txt
if [ $failcount -gt 0 ]
then
echo "FAILURE!" >> ${logfile}
exit 1
else
echo "SUCCESS!" >> ${logfile}
exit 0
fi
But this runs the scripts sequentially and NOT parallely. I need to start all the scripts parallely using nohup(or any other means if possible) and should be able to track their exit status individually.
Kindly help.
Cheers.