Use some kind of process manager e.g pm2 for this. It will be more stable than that.
The python file in question collects data from API and the server is down once in a while so it stops running. to solve this, I've written this batch file that would keep running the file even if it encounters an error, so in few minutes it would be running as usual.
:1
python3 datacollection.py
goto 1


Now, how do I achieve the same with bash file?
Note: I want to run the python file on AWS EC2 Ubuntu.
bash code to run python file continuously