I am running my Python script on the server. It connects to the database and appends the results to the file. So that the new row with the result is always written at the end of the file. However, if the connection with the server is broken, I will have to run it again from where it finished last time. Is it possible to make the Python script automatically ssh to the server and run the Python script again without a human interaction?
Run the script like this
ssh user@host "nohup python -u" - < script.py &
nohup stops the program terminating on the server if the connection is lost
& at the end means to run this command in the background, so your local terminal can do other stuff without waiting for the ssh to complete.
Test it by