Instead exit made a condition, but now it exits and doesn’t start
def restart_script():
"""Function to restart the script"""
print("Restarting script...")
# Save any data here if needed
if __name__ == "__main__":
# Set the maximum number of iterations
max_iterations = 10
num_iterations = 0
# Schedule to run the function every hour
schedule.every(5).seconds.do(restart_script)
# Keep the script running for a maximum number of iterations
while num_iterations < max_iterations:
schedule.run_pending()
time.sleep(1)
num_iterations += 1