Monday 2 April 2018

ssh, screen, run command and detach in one go?


I like to start a server (basically a jupiter-notebook) in a screen session within an SSH, let it run and then detach immediately. doing it one by one:


ssh USER@HOST
screen -d -m /home/USER/anaconda3/bin/jupyter-notebook --ip HOST --port 8889 --no-browser

then detach from screen and finally disconnect from SSH. Then use the server. Everything works in this case. One can also see that the screen is running by


ssh -t USER@HOST screen -ls

Now how do I do the former in one go?


ssh -t USER@HOST "screen -d -m /home/USER/anaconda3/bin/jupyter-notebook --ip HOST --port 8889 --no-browser"

does not work. What am I doing wrong?


thanks



Answer



You are quite close, but you don't need the TTY for screen to startup - it creates it's own PTY. But you do need to put the ssh session in the background allowing the screen process to continue running, as in:


ssh -f USER@HOST 'screen -dm command'

Might also see this answer for other things you can do to the running screen session if you name it.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...