#!/bin/bash # Set the maximum number of retries max_retries=5 retries=0 while [ $retries -lt $max_retries ]; do # Run your Python script python main.py # Check the exit code of the Python script if [ $? -ne 0 ]; then echo "Error occurred. Retrying..." retries=$((retries + 1)) else echo "Script executed successfully." retries=0 break fi done if [ $retries -eq $max_retries ]; then echo "Max retries reached. Exiting." exit 1 fi