I recently ran into an interesting situation that required me to run a Python script repeatedly with different inputs on a remote server. Of course, with any SSH session, there is always the possibility of a timeout which would kill any running jobs. Normally, I would simply deploy a program and use an & at the end of the command, allowing the job to run in the background even after I logged out of my SSH session. Seeing that I had multiple scripts to run, and could simply adjust my inputs with a for loop, I created a bash script that repeatedly called my Python code. This was pretty straightforward and I deployed the script with an & before logging out of my SSH session to let the job complete.
Bash Scripts, Python, SSH and Screen: Keeping Your Jobs Alive!
Leave a reply