Issue
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.
Solution
Just to add to @Willian Pursell answer. You could run screen
command on your AWS server, then run while sleep 1; do python3 datacollection.py; done
in your newly created session. Finally detach to the session using Ctrl
+ ad
keys. With that, you will be able to exit your session. Exit the server, the command will keep running on the background. Cheers.
Answered By - programandoconro