The overall question here is - how do I automate sshing into a machine, running a script, and exiting without killing the script? I know that this has been answered several times, but I'm not having luck with the solutions I've found.
I have code running on several machines that I ssh into.
Right now, I'm doing the following in a terminal:
ssh machine1@host (log in automatically with key) screen -S screen_name ./script.sh <keystroke C-a-d> exit
Time consuming, and more importantly, prone to errors (open a screen and exit it without running the script, etc.).
I'd like to automate this. My first thought was to try to replicate this exactly. I tried xdotool to send the keystrokes, but my environment is command line only, and it seems like the wrong tool for the job. Similarly expect looks like it could be used instead of xdotool, but again, probably the wrong way to do it.
I also tried using nohup instead of screen, by doing nohup ./script.sh &
but when I log out of the ssh session and come back, it looks like the script stopped running when I logged out. As far as I can tell, nohup is the right way to do it.