Ssh – Starting a background screen session from ssh.

command-line-interfacegnu-screenssh

I would like to shoot a command to server to be run say forever! under "screen session" using ssh.

so I am using something like

ssh -t root@server screen -S myinf "python infinit1.py &"

where infinit1.py is the script. The problem the "python infinit1.py" doesn't go in a background and neither a screen called "myinf" is created.

I appreciate your hints.

Best Answer

This is because screen as invoked by you requires a pty to function. You will need to start screen in detached mode:

ssh root@server screen -d -m -S myinf python infinit1.py