Posted over 9 years ago. Visible to the public. Repeats.

How to run long scripts on production/staging server

In a nutshell, use screen

Sometimes we are concerned that if our connection gets closed, the process we are running will close too.

The processes or login sessions you establish through screen don't go away. You can resume your screen sessions.


  1. run screen command
    or you can give that screen a name (will help afterwards)
    screen -S some_name

  2. run your time consuming command
    script/runner path_to_some_long_script.rb

  3. detatch from your screen with the following commands

  • Crtl + A
  • d
  1. to reattach run
    screen -r some_name

  2. to exit the screen run
    exit :)

to see all screens you can run (it will show the screen PID and name)
screen -ls

you can reattach a screen by giving it's name or it's PID
screen -r some_name or screen -r PID

if there is only one screen, then you can use simply
screen -r

can be used for other things not only for running lengthy scripts

Owner of this card:

Dragos Miron
Last edit:
over 4 years ago
Posted by Dragos Miron to HouseTrip Deck
This website uses short-lived cookies to improve usability.
Accept or learn more