Search code examples
sshgnu-screen

Remotely starting a screen session through ssh and closing the ssh session immediately


My goal is to remote to a server through ssh, start a screen, start a script, let the script run, and exit the ssh session while keeping the screen running its own python script. This is what I have:

ssh -t myuser@hostname screen python somepath.py -s 'potato'

The problem with this is, after I run it, I have to manually ctrl + a + d, and exit out of the ssh session myself. Is there a way to do it all in one go without needing human interaction?


Solution

  • add -d -m to the screen command. remove -t

    Try this:

    ssh myuser@hostname screen -d -m python somepath.py