I read the manual and online help, but still cannot grasp the idea of the screen command. Lets say I SSH to my linux shell. Inside it I want to run a program that will run for 8 hours:

  1. I create a "detached screen" by entering screen and then crtl+a, crtl+d to deattach it.
  2. Then I run my program my_prog

What to do then? How do I return back to my normal terminal and continue my normal session started with? If I just close the SSH window and reconnect, then my program stops.

My question is that exact steps I must make to:

  1. Work in the shell as normal
  2. Run screen to run a program in the background
  3. Continue working in the old shell
  4. Exit the SSH session
  5. Establish a new SSH session and switch to my program that has worked while I was gone

Or is it the other way around? I enter my_prog &, then call screen and detach and then close the terminal window?

1 Answer 1

  1. You start screen,
  2. Run the program in screen,
  3. And then detach it.
  4. screen -R to attach it again.

If you run many independent screen sessions, then use the -S option to name your sessions and to attach named sessions, or use -ls to list existing sessions, and attach to those.

  • Thanks, now I get it. I thought it was the other way around, that screen makes a detached session.
    – Jake B.
    Commented Apr 7, 2020 at 15:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .