I'm struggling with a bit of basic logic and i'm hoping someone can help me out.
I've written a little whole loop to run through a file and determine if the transfer failed or was skipped.
If it wasn't then it declares "BACKUP IS GOOD" and exits cleanly. If it has failed then it declares "BACKUP IS NOT GOOD" until it reaches the max retries of 5.
The theory being that if the file that is being checked changes (anywhere in those 5 runs) that it will then change to "BACKUP IS GOOD".
The problem i'm having is that the loop isn't catching this change.
Any advice would be appreciated.
max_retries="5"
backup_count="1"
failed=$(grep -c "Transfer failed: 0" "mylog.txt")
skipped=$(grep -c "Transfer skipped: 0" "mylog.txt")
while (( $max_retries >= $backup_count ))
do
if (( $skipped == 1 )) && (( $failed == 1 )); then
echo "BACKUP IS GOOD"
exit 0
elif (( $skipped != 1 )) || (( $failed != 1 )); then
echo "BACKUP IS NOT GOOD"
sleep 15
(( backup_count++ ))
fi
done
grepagain. What are you expecting? That the variables are gonna change themselves magically? :)