Screen is a small linux utility which can help you run long-running jobs in remote shell without worrying about loosing network connection.
Once a process is started inside screen session, if your network connection breaks or you choose to close terminal (without exit), you can resume into that screen session anytime from anywhere.
apt-get install screen
Create a screen
You can specify a
screen -S name
Or even create screen without name
Detach a screen
Never use “exit” inside screen. It will end “screen” session.
You keyboard shortcut CTRL+A+D
You will see
There are screens on: 7142.name (10/19/13 12:43:39) (Detached) 7127.pts-0.test3 (10/19/13 12:42:25) (Detached) 2 Sockets in /var/run/screen/S-root.
pts-0.test3 is name of screen which was created without specifying screen name explicitly.
Reattatch a screen
Run following to reattach a detached screen
screen -r name
-d flag to force detach on a screen attached elsewhere
screen -d -r name
As you can create screens with same name, in case you have screen with same, you need to specify pid like below:
screen -r 7142
Create a new screen within a screen
I never needed this myself, but its possible to create CTRL+A+C
You can also create a new screen using normal
screen -S name command.