Keep process running after ending the ssh session using "screen"

Simple scenario from askubuntu:
  • ssh into your remote box. Type screen Then start the process you want.
  • Press Ctrl-A then Ctrl-D. This will "detach" your screen session but leave your processes running. You can now log out of the remote box.
  • If you want to come back later, log on again and type screen -r This will "resume" your screen session, and you can see the output of your process. However, if you have multiple screens have been detached before, you might get this below:





  • In this case, just specify the screen you want to re-attach
    • screen -r 174044.pts-3.srvgal107
  • Kill screen session : Press Ctrl-A then K.
  • Access attatched screen : screen -D -r '1234.somescreensession'
  • Scroll inside screen
    • Maybe there's a better way, but I'm used to scrolling using the "copy mode" (which you can use to copy text using screen itself, although that requires the paste command too):
      • Hit your screen prefix combination (C-a / control+A by default), then hit Escape.
      • Move up/down with the arrow keys ( and ).
      • When you're done, hit Return twice to get back to the end of the scroll buffer.
      (If you move the cursor after hitting Return once, you'll be selecting text to copy, and hitting Return the second time will copy it. Then you can paste with C-a followed by] )
  • Quite a session: screen -X -S [session # you want to kill] quit